diff --git a/flytestdlib/fastcheck/iface.go b/flytestdlib/fastcheck/iface.go index e9d0637ad7..2c285b9b88 100644 --- a/flytestdlib/fastcheck/iface.go +++ b/flytestdlib/fastcheck/iface.go @@ -12,6 +12,9 @@ import ( // For example an LRU cache, may have an overhead because of the use of a HashMap with loading factor and collision // resolution // The Data-structure is thread-safe and can be accessed by multiple threads concurrently. + +//go:generate mockery -name Filter -case=underscore + type Filter interface { // Contains returns a True if the id was previously seen or false otherwise // It may return a false, even if a item may have previously occurred. diff --git a/flytestdlib/fastcheck/mocks/filter.go b/flytestdlib/fastcheck/mocks/filter.go new file mode 100644 index 0000000000..04b31555a8 --- /dev/null +++ b/flytestdlib/fastcheck/mocks/filter.go @@ -0,0 +1,78 @@ +// Code generated by mockery v1.0.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// Filter is an autogenerated mock type for the Filter type +type Filter struct { + mock.Mock +} + +type Filter_Add struct { + *mock.Call +} + +func (_m Filter_Add) Return(evicted bool) *Filter_Add { + return &Filter_Add{Call: _m.Call.Return(evicted)} +} + +func (_m *Filter) OnAdd(ctx context.Context, id []byte) *Filter_Add { + c := _m.On("Add", ctx, id) + return &Filter_Add{Call: c} +} + +func (_m *Filter) OnAddMatch(matchers ...interface{}) *Filter_Add { + c := _m.On("Add", matchers...) + return &Filter_Add{Call: c} +} + +// Add provides a mock function with given fields: ctx, id +func (_m *Filter) Add(ctx context.Context, id []byte) bool { + ret := _m.Called(ctx, id) + + var r0 bool + if rf, ok := ret.Get(0).(func(context.Context, []byte) bool); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +type Filter_Contains struct { + *mock.Call +} + +func (_m Filter_Contains) Return(_a0 bool) *Filter_Contains { + return &Filter_Contains{Call: _m.Call.Return(_a0)} +} + +func (_m *Filter) OnContains(ctx context.Context, id []byte) *Filter_Contains { + c := _m.On("Contains", ctx, id) + return &Filter_Contains{Call: c} +} + +func (_m *Filter) OnContainsMatch(matchers ...interface{}) *Filter_Contains { + c := _m.On("Contains", matchers...) + return &Filter_Contains{Call: c} +} + +// Contains provides a mock function with given fields: ctx, id +func (_m *Filter) Contains(ctx context.Context, id []byte) bool { + ret := _m.Called(ctx, id) + + var r0 bool + if rf, ok := ret.Get(0).(func(context.Context, []byte) bool); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} diff --git a/flytestdlib/sets/generic_set_test.go b/flytestdlib/sets/generic_set_test.go index 9d9f165ed5..ac95a64726 100644 --- a/flytestdlib/sets/generic_set_test.go +++ b/flytestdlib/sets/generic_set_test.go @@ -64,7 +64,15 @@ func TestGenericSet(t *testing.T) { assert.True(t, g2.IsSuperset(g1)) assert.False(t, g1.IsSuperset(g2)) } + { + g1 := NewGeneric(GenericVal("a"), GenericVal("b")) + g2 := g1.UnsortedListKeys() + assert.Equal(t, g1.Len(), len(g2)) + for _, key := range g2 { + assert.True(t, g1.Has(GenericVal(key))) + } + } { g1 := NewGeneric(GenericVal("a"), GenericVal("b")) assert.True(t, g1.Has(GenericVal("a")))