Skip to content

Commit

Permalink
Increase factory code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Putilov <[email protected]>
  • Loading branch information
m8rge committed Sep 23, 2020
1 parent 239639a commit a3111df
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions plugin/storage/grpc/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ func (b *mockPluginBuilder) Build() (*grpcConfig.ClientPluginServices, error) {
return nil, b.err
}

return &grpcConfig.ClientPluginServices{
services := &grpcConfig.ClientPluginServices{
PluginServices: shared.PluginServices{
Store: b.plugin,
ArchiveStore: b.plugin,
},
Capabilities: b.plugin,
}, nil
}
if b.plugin.capabilities != nil {
services.Capabilities = b.plugin
}

return services, nil
}

type mockPlugin struct {
Expand Down Expand Up @@ -215,6 +219,28 @@ func TestGRPCStorageFactory_CapabilitiesError(t *testing.T) {
assert.Nil(t, writer)
}

func TestGRPCStorageFactory_CapabilitiesNil(t *testing.T) {
f := NewFactory()
v := viper.New()
f.InitFromViper(v)

f.builder = &mockPluginBuilder{
plugin: &mockPlugin{
archiveWriter: new(spanStoreMocks.Writer),
archiveReader: new(spanStoreMocks.Reader),
},
}
assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop()))

assert.NotNil(t, f.store)
reader, err := f.CreateArchiveSpanReader()
assert.Equal(t, err, storage.ErrArchiveStorageNotSupported)
assert.Nil(t, reader)
writer, err := f.CreateArchiveSpanWriter()
assert.Equal(t, err, storage.ErrArchiveStorageNotSupported)
assert.Nil(t, writer)
}

func TestWithConfiguration(t *testing.T) {
f := NewFactory()
v, command := config.Viperize(f.AddFlags)
Expand Down

0 comments on commit a3111df

Please sign in to comment.