Skip to content

Commit

Permalink
Add Unit Tests For New Factory Method
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Nov 7, 2024
1 parent 9cacd61 commit 0620370
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ func TestAdapterClose(t *testing.T) {
require.NoError(t, f.Close(context.Background()))
}

func TestAdapterCreateTraceReader(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("create trace reader did not panic")
}
}()
func TestAdapter_CreateTraceReader_Error(t *testing.T) {
f1 := new(factoryMocks.Factory)
f1.On("CreateSpanReader").Return(nil, errors.New("mock error"))

f := &Factory{}
f.CreateTraceReader()
f := NewFactory(f1)
_, err := f.CreateTraceReader()
require.ErrorContains(t, err, "mock error")
}

func TestAdapter_CreateTraceReader_NoError(t *testing.T) {
f1 := new(factoryMocks.Factory)
f1.On("CreateSpanReader").Return(new(spanstoreMocks.Reader), nil)

f := NewFactory(f1)
_, err := f.CreateTraceReader()
require.NoError(t, err)
}

func TestAdapterCreateTraceWriterError(t *testing.T) {
Expand Down

0 comments on commit 0620370

Please sign in to comment.