Skip to content

Commit

Permalink
Repository factory new tests. (#207)
Browse files Browse the repository at this point in the history
# Describe Request

Repository factory new test.

# Change Type

New feature.
  • Loading branch information
cinar authored Sep 7, 2024
1 parent 17ec52a commit cba1c86
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions asset/repository_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ import (
"github.com/cinar/indicator/v2/asset"
)

func TestNewRepositoryUnknown(t *testing.T) {
repository, err := asset.NewRepository("unknown", "")
if err == nil {
t.Fatalf("unknown repository: %T", repository)
}
}

func TestRegisterRepositoryBuilder(t *testing.T) {
builderName := "testbuilder"

repository, err := asset.NewRepository(builderName, "")
if err == nil {
t.Fatalf("testbuilder is: %T", repository)
}

asset.RegisterRepositoryBuilder(builderName, func(_ string) (asset.Repository, error) {
return asset.NewInMemoryRepository(), nil
})

repository, err = asset.NewRepository(builderName, "")
if err != nil {
t.Fatalf("testbuilder is not found: %v", err)
}

_, ok := repository.(*asset.InMemoryRepository)
if !ok {
t.Fatalf("testbuilder is: %T", repository)
}
}

func TestNewRepositoryMemory(t *testing.T) {
repository, err := asset.NewRepository(asset.InMemoryRepositoryBuilderName, "")
if err != nil {
Expand Down

0 comments on commit cba1c86

Please sign in to comment.