Skip to content

Commit

Permalink
fix: init in-memory files and shard repositories as defaults
Browse files Browse the repository at this point in the history
Fixes: #238
  • Loading branch information
adamdecaf committed Aug 21, 2024
1 parent dabbf9c commit 0619dbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ func NewEnvironment(env *Environment) (*Environment, error) {
fileRepository = files.NewRepository(env.DB)
shardRepository = shards.NewRepository(env.DB, env.Config.Sharding.Mappings)
}

if env.SpannerClient != nil {
fileRepository = files.NewSpannerRepository(env.SpannerClient)
shardRepository = shards.NewSpannerRepository(env.SpannerClient, env.Config.Sharding.Mappings)
}
if fileRepository == nil {
fileRepository = files.NewMockRepository()
}
if shardRepository == nil {
shardRepository = shards.NewInMemoryRepository()
}

fileReceiver, err := pipeline.Start(ctx, env.Logger, env.Config, shardRepository, fileRepository, httpSub)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/files/mock_repo_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ type MockRepository struct {
Err error
}

func NewMockRepository() Repository {
return &MockRepository{}
}

func (r *MockRepository) Record(_ context.Context, file AcceptedFile) error {
return r.Err
}
Expand Down

0 comments on commit 0619dbc

Please sign in to comment.