diff --git a/.mockery.yaml b/.mockery.yaml index c6027e9..1980cec 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -1,10 +1,10 @@ issue-845-fix: True resolve-type-alias: False with-expecter: True -filename: 'mock_{{.InterfaceName}}.go' -dir: 'pkg/internal/testutil/mocks' -mockname: 'Mock{{.InterfaceName}}' -outpkg: 'mocks' +inpackage: True +filename: "mock_{{.InterfaceName}}.go" +dir: "{{.InterfaceDir}}" +mockname: "Mock{{.InterfaceName}}" packages: github.com/storacha/indexing-service/pkg/service/providerindex: interfaces: @@ -14,7 +14,7 @@ packages: interfaces: Finder: config: - filename: 'mock_ContentClaimsFinder.go' + filename: mock_ContentClaimsFinder.go mockname: MockContentClaimsFinder github.com/storacha/indexing-service/pkg/types: interfaces: @@ -24,9 +24,27 @@ packages: github.com/aws/aws-sdk-go-v2/service/dynamodb: interfaces: QueryAPIClient: + config: + inpackage: False + dir: "pkg/internal/testutil/extmocks" + outpkg: "extmocks" + filename: mock_DynamoDBQueryClient.go + mockname: MockDynamoDBQueryClient github.com/ipni/go-libipni/find/client: interfaces: Finder: + config: + inpackage: False + dir: "pkg/internal/testutil/extmocks" + outpkg: "extmocks" + filename: mock_IpniFinder.go + mockname: MockIpniFinder github.com/storacha/ipni-publisher/pkg/publisher: interfaces: Publisher: + config: + inpackage: False + dir: "pkg/internal/testutil/extmocks" + outpkg: "extmocks" + filename: mock_IpniPublisher.go + mockname: MockIpniPublisher diff --git a/pkg/aws/dynamocontenttoclaimsmapper_test.go b/pkg/aws/dynamocontenttoclaimsmapper_test.go index 6d5d71b..1002469 100644 --- a/pkg/aws/dynamocontenttoclaimsmapper_test.go +++ b/pkg/aws/dynamocontenttoclaimsmapper_test.go @@ -10,7 +10,7 @@ import ( "github.com/ipfs/go-cid" "github.com/storacha/indexing-service/pkg/internal/link" "github.com/storacha/indexing-service/pkg/internal/testutil" - "github.com/storacha/indexing-service/pkg/internal/testutil/mocks" + "github.com/storacha/indexing-service/pkg/internal/testutil/extmocks" "github.com/storacha/indexing-service/pkg/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -20,7 +20,7 @@ func TestGetClaims(t *testing.T) { testTable := "sometable" t.Run("happy path", func(t *testing.T) { - mockDynamoDBClient := mocks.NewMockQueryAPIClient(t) + mockDynamoDBClient := extmocks.NewMockDynamoDBQueryClient(t) dynamoDBMapper := NewDynamoContentToClaimsMapper(mockDynamoDBClient, testTable) contentHash := testutil.RandomMultihash() @@ -55,7 +55,7 @@ func TestGetClaims(t *testing.T) { }) t.Run("returns ErrKeyNotFound when there are no results in the DB", func(t *testing.T) { - mockDynamoDBClient := mocks.NewMockQueryAPIClient(t) + mockDynamoDBClient := extmocks.NewMockDynamoDBQueryClient(t) dynamoDBMapper := NewDynamoContentToClaimsMapper(mockDynamoDBClient, testTable) ctx := context.Background() diff --git a/pkg/internal/testutil/mocks/mock_QueryAPIClient.go b/pkg/internal/testutil/extmocks/mock_DynamoDBQueryClient.go similarity index 53% rename from pkg/internal/testutil/mocks/mock_QueryAPIClient.go rename to pkg/internal/testutil/extmocks/mock_DynamoDBQueryClient.go index f112555..866f092 100644 --- a/pkg/internal/testutil/mocks/mock_QueryAPIClient.go +++ b/pkg/internal/testutil/extmocks/mock_DynamoDBQueryClient.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package extmocks import ( context "context" @@ -9,21 +9,21 @@ import ( mock "github.com/stretchr/testify/mock" ) -// MockQueryAPIClient is an autogenerated mock type for the QueryAPIClient type -type MockQueryAPIClient struct { +// MockDynamoDBQueryClient is an autogenerated mock type for the QueryAPIClient type +type MockDynamoDBQueryClient struct { mock.Mock } -type MockQueryAPIClient_Expecter struct { +type MockDynamoDBQueryClient_Expecter struct { mock *mock.Mock } -func (_m *MockQueryAPIClient) EXPECT() *MockQueryAPIClient_Expecter { - return &MockQueryAPIClient_Expecter{mock: &_m.Mock} +func (_m *MockDynamoDBQueryClient) EXPECT() *MockDynamoDBQueryClient_Expecter { + return &MockDynamoDBQueryClient_Expecter{mock: &_m.Mock} } // Query provides a mock function with given fields: _a0, _a1, _a2 -func (_m *MockQueryAPIClient) Query(_a0 context.Context, _a1 *dynamodb.QueryInput, _a2 ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error) { +func (_m *MockDynamoDBQueryClient) Query(_a0 context.Context, _a1 *dynamodb.QueryInput, _a2 ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error) { _va := make([]interface{}, len(_a2)) for _i := range _a2 { _va[_i] = _a2[_i] @@ -59,8 +59,8 @@ func (_m *MockQueryAPIClient) Query(_a0 context.Context, _a1 *dynamodb.QueryInpu return r0, r1 } -// MockQueryAPIClient_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' -type MockQueryAPIClient_Query_Call struct { +// MockDynamoDBQueryClient_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' +type MockDynamoDBQueryClient_Query_Call struct { *mock.Call } @@ -68,12 +68,12 @@ type MockQueryAPIClient_Query_Call struct { // - _a0 context.Context // - _a1 *dynamodb.QueryInput // - _a2 ...func(*dynamodb.Options) -func (_e *MockQueryAPIClient_Expecter) Query(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockQueryAPIClient_Query_Call { - return &MockQueryAPIClient_Query_Call{Call: _e.mock.On("Query", +func (_e *MockDynamoDBQueryClient_Expecter) Query(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDynamoDBQueryClient_Query_Call { + return &MockDynamoDBQueryClient_Query_Call{Call: _e.mock.On("Query", append([]interface{}{_a0, _a1}, _a2...)...)} } -func (_c *MockQueryAPIClient_Query_Call) Run(run func(_a0 context.Context, _a1 *dynamodb.QueryInput, _a2 ...func(*dynamodb.Options))) *MockQueryAPIClient_Query_Call { +func (_c *MockDynamoDBQueryClient_Query_Call) Run(run func(_a0 context.Context, _a1 *dynamodb.QueryInput, _a2 ...func(*dynamodb.Options))) *MockDynamoDBQueryClient_Query_Call { _c.Call.Run(func(args mock.Arguments) { variadicArgs := make([]func(*dynamodb.Options), len(args)-2) for i, a := range args[2:] { @@ -86,23 +86,23 @@ func (_c *MockQueryAPIClient_Query_Call) Run(run func(_a0 context.Context, _a1 * return _c } -func (_c *MockQueryAPIClient_Query_Call) Return(_a0 *dynamodb.QueryOutput, _a1 error) *MockQueryAPIClient_Query_Call { +func (_c *MockDynamoDBQueryClient_Query_Call) Return(_a0 *dynamodb.QueryOutput, _a1 error) *MockDynamoDBQueryClient_Query_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockQueryAPIClient_Query_Call) RunAndReturn(run func(context.Context, *dynamodb.QueryInput, ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)) *MockQueryAPIClient_Query_Call { +func (_c *MockDynamoDBQueryClient_Query_Call) RunAndReturn(run func(context.Context, *dynamodb.QueryInput, ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)) *MockDynamoDBQueryClient_Query_Call { _c.Call.Return(run) return _c } -// NewMockQueryAPIClient creates a new instance of MockQueryAPIClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockDynamoDBQueryClient creates a new instance of MockDynamoDBQueryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewMockQueryAPIClient(t interface { +func NewMockDynamoDBQueryClient(t interface { mock.TestingT Cleanup(func()) -}) *MockQueryAPIClient { - mock := &MockQueryAPIClient{} +}) *MockDynamoDBQueryClient { + mock := &MockDynamoDBQueryClient{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/pkg/internal/testutil/mocks/mock_Finder.go b/pkg/internal/testutil/extmocks/mock_IpniFinder.go similarity index 51% rename from pkg/internal/testutil/mocks/mock_Finder.go rename to pkg/internal/testutil/extmocks/mock_IpniFinder.go index 6399105..5562fb1 100644 --- a/pkg/internal/testutil/mocks/mock_Finder.go +++ b/pkg/internal/testutil/extmocks/mock_IpniFinder.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package extmocks import ( context "context" @@ -11,21 +11,21 @@ import ( multihash "github.com/multiformats/go-multihash" ) -// MockFinder is an autogenerated mock type for the Finder type -type MockFinder struct { +// MockIpniFinder is an autogenerated mock type for the Finder type +type MockIpniFinder struct { mock.Mock } -type MockFinder_Expecter struct { +type MockIpniFinder_Expecter struct { mock *mock.Mock } -func (_m *MockFinder) EXPECT() *MockFinder_Expecter { - return &MockFinder_Expecter{mock: &_m.Mock} +func (_m *MockIpniFinder) EXPECT() *MockIpniFinder_Expecter { + return &MockIpniFinder_Expecter{mock: &_m.Mock} } // Find provides a mock function with given fields: _a0, _a1 -func (_m *MockFinder) Find(_a0 context.Context, _a1 multihash.Multihash) (*model.FindResponse, error) { +func (_m *MockIpniFinder) Find(_a0 context.Context, _a1 multihash.Multihash) (*model.FindResponse, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { @@ -54,42 +54,42 @@ func (_m *MockFinder) Find(_a0 context.Context, _a1 multihash.Multihash) (*model return r0, r1 } -// MockFinder_Find_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Find' -type MockFinder_Find_Call struct { +// MockIpniFinder_Find_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Find' +type MockIpniFinder_Find_Call struct { *mock.Call } // Find is a helper method to define mock.On call // - _a0 context.Context // - _a1 multihash.Multihash -func (_e *MockFinder_Expecter) Find(_a0 interface{}, _a1 interface{}) *MockFinder_Find_Call { - return &MockFinder_Find_Call{Call: _e.mock.On("Find", _a0, _a1)} +func (_e *MockIpniFinder_Expecter) Find(_a0 interface{}, _a1 interface{}) *MockIpniFinder_Find_Call { + return &MockIpniFinder_Find_Call{Call: _e.mock.On("Find", _a0, _a1)} } -func (_c *MockFinder_Find_Call) Run(run func(_a0 context.Context, _a1 multihash.Multihash)) *MockFinder_Find_Call { +func (_c *MockIpniFinder_Find_Call) Run(run func(_a0 context.Context, _a1 multihash.Multihash)) *MockIpniFinder_Find_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(multihash.Multihash)) }) return _c } -func (_c *MockFinder_Find_Call) Return(_a0 *model.FindResponse, _a1 error) *MockFinder_Find_Call { +func (_c *MockIpniFinder_Find_Call) Return(_a0 *model.FindResponse, _a1 error) *MockIpniFinder_Find_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockFinder_Find_Call) RunAndReturn(run func(context.Context, multihash.Multihash) (*model.FindResponse, error)) *MockFinder_Find_Call { +func (_c *MockIpniFinder_Find_Call) RunAndReturn(run func(context.Context, multihash.Multihash) (*model.FindResponse, error)) *MockIpniFinder_Find_Call { _c.Call.Return(run) return _c } -// NewMockFinder creates a new instance of MockFinder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockIpniFinder creates a new instance of MockIpniFinder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewMockFinder(t interface { +func NewMockIpniFinder(t interface { mock.TestingT Cleanup(func()) -}) *MockFinder { - mock := &MockFinder{} +}) *MockIpniFinder { + mock := &MockIpniFinder{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/pkg/internal/testutil/mocks/mock_Publisher.go b/pkg/internal/testutil/extmocks/mock_IpniPublisher.go similarity index 54% rename from pkg/internal/testutil/mocks/mock_Publisher.go rename to pkg/internal/testutil/extmocks/mock_IpniPublisher.go index bf5a14a..5eed947 100644 --- a/pkg/internal/testutil/mocks/mock_Publisher.go +++ b/pkg/internal/testutil/extmocks/mock_IpniPublisher.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package extmocks import ( context "context" @@ -17,21 +17,21 @@ import ( peer "github.com/libp2p/go-libp2p/core/peer" ) -// MockPublisher is an autogenerated mock type for the Publisher type -type MockPublisher struct { +// MockIpniPublisher is an autogenerated mock type for the Publisher type +type MockIpniPublisher struct { mock.Mock } -type MockPublisher_Expecter struct { +type MockIpniPublisher_Expecter struct { mock *mock.Mock } -func (_m *MockPublisher) EXPECT() *MockPublisher_Expecter { - return &MockPublisher_Expecter{mock: &_m.Mock} +func (_m *MockIpniPublisher) EXPECT() *MockIpniPublisher_Expecter { + return &MockIpniPublisher_Expecter{mock: &_m.Mock} } // Publish provides a mock function with given fields: ctx, provider, contextID, digests, meta -func (_m *MockPublisher) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) (ipld.Link, error) { +func (_m *MockIpniPublisher) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) (ipld.Link, error) { ret := _m.Called(ctx, provider, contextID, digests, meta) if len(ret) == 0 { @@ -60,8 +60,8 @@ func (_m *MockPublisher) Publish(ctx context.Context, provider peer.AddrInfo, co return r0, r1 } -// MockPublisher_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish' -type MockPublisher_Publish_Call struct { +// MockIpniPublisher_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish' +type MockIpniPublisher_Publish_Call struct { *mock.Call } @@ -71,34 +71,34 @@ type MockPublisher_Publish_Call struct { // - contextID string // - digests iter.Seq[multihash.Multihash] // - meta metadata.Metadata -func (_e *MockPublisher_Expecter) Publish(ctx interface{}, provider interface{}, contextID interface{}, digests interface{}, meta interface{}) *MockPublisher_Publish_Call { - return &MockPublisher_Publish_Call{Call: _e.mock.On("Publish", ctx, provider, contextID, digests, meta)} +func (_e *MockIpniPublisher_Expecter) Publish(ctx interface{}, provider interface{}, contextID interface{}, digests interface{}, meta interface{}) *MockIpniPublisher_Publish_Call { + return &MockIpniPublisher_Publish_Call{Call: _e.mock.On("Publish", ctx, provider, contextID, digests, meta)} } -func (_c *MockPublisher_Publish_Call) Run(run func(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata)) *MockPublisher_Publish_Call { +func (_c *MockIpniPublisher_Publish_Call) Run(run func(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata)) *MockIpniPublisher_Publish_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(peer.AddrInfo), args[2].(string), args[3].(iter.Seq[multihash.Multihash]), args[4].(metadata.Metadata)) }) return _c } -func (_c *MockPublisher_Publish_Call) Return(_a0 ipld.Link, _a1 error) *MockPublisher_Publish_Call { +func (_c *MockIpniPublisher_Publish_Call) Return(_a0 ipld.Link, _a1 error) *MockIpniPublisher_Publish_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockPublisher_Publish_Call) RunAndReturn(run func(context.Context, peer.AddrInfo, string, iter.Seq[multihash.Multihash], metadata.Metadata) (ipld.Link, error)) *MockPublisher_Publish_Call { +func (_c *MockIpniPublisher_Publish_Call) RunAndReturn(run func(context.Context, peer.AddrInfo, string, iter.Seq[multihash.Multihash], metadata.Metadata) (ipld.Link, error)) *MockIpniPublisher_Publish_Call { _c.Call.Return(run) return _c } -// NewMockPublisher creates a new instance of MockPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockIpniPublisher creates a new instance of MockIpniPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewMockPublisher(t interface { +func NewMockIpniPublisher(t interface { mock.TestingT Cleanup(func()) -}) *MockPublisher { - mock := &MockPublisher{} +}) *MockIpniPublisher { + mock := &MockIpniPublisher{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/pkg/internal/testutil/mocks/mock_ContentClaimsFinder.go b/pkg/service/contentclaims/mock_ContentClaimsFinder.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_ContentClaimsFinder.go rename to pkg/service/contentclaims/mock_ContentClaimsFinder.go index fa60398..95aa6a6 100644 --- a/pkg/internal/testutil/mocks/mock_ContentClaimsFinder.go +++ b/pkg/service/contentclaims/mock_ContentClaimsFinder.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package contentclaims import ( context "context" diff --git a/pkg/service/providerindex/legacy_test.go b/pkg/service/providerindex/legacy_test.go index aa70e07..1afcec3 100644 --- a/pkg/service/providerindex/legacy_test.go +++ b/pkg/service/providerindex/legacy_test.go @@ -10,7 +10,7 @@ import ( "github.com/storacha/indexing-service/pkg/internal/digestutil" "github.com/storacha/indexing-service/pkg/internal/link" "github.com/storacha/indexing-service/pkg/internal/testutil" - "github.com/storacha/indexing-service/pkg/internal/testutil/mocks" + "github.com/storacha/indexing-service/pkg/service/contentclaims" "github.com/storacha/indexing-service/pkg/types" "github.com/ipfs/go-cid" @@ -26,8 +26,8 @@ import ( func TestFind(t *testing.T) { t.Run("happy path, unsupported claims are filtered out", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) ctx := context.Background() @@ -57,8 +57,8 @@ func TestFind(t *testing.T) { }) t.Run("returns no error, but empty results, when the content hash is not found in the mapper", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) mockMapper.EXPECT().GetClaims(mock.Anything, mock.Anything).Return(nil, types.ErrKeyNotFound) @@ -70,8 +70,8 @@ func TestFind(t *testing.T) { }) t.Run("returns no error, but empty results, when claims are not found in the store", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) testCID := link.ToCID(testutil.RandomCID()) @@ -88,8 +88,8 @@ func TestFind(t *testing.T) { func TestSynthetizeProviderResult(t *testing.T) { t.Run("location claim", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) contentLink := testutil.RandomCID() @@ -128,8 +128,8 @@ func TestSynthetizeProviderResult(t *testing.T) { }) t.Run("index claim", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) contentLink := testutil.RandomCID() @@ -162,8 +162,8 @@ func TestSynthetizeProviderResult(t *testing.T) { }) t.Run("equals claim", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) contentHash := link.ToCID(testutil.RandomCID()).Hash() @@ -197,8 +197,8 @@ func TestSynthetizeProviderResult(t *testing.T) { }) t.Run("unsupported claim", func(t *testing.T) { - mockMapper := mocks.NewMockContentToClaimsMapper(t) - mockStore := mocks.NewMockContentClaimsFinder(t) + mockMapper := NewMockContentToClaimsMapper(t) + mockStore := contentclaims.NewMockContentClaimsFinder(t) legacyClaims := testutil.Must(NewLegacyClaimsStore(mockMapper, mockStore, "https://storacha.network/claims/{claim}"))(t) contentHash := link.ToCID(testutil.RandomCID()).Hash() diff --git a/pkg/internal/testutil/mocks/mock_ContentToClaimsMapper.go b/pkg/service/providerindex/mock_ContentToClaimsMapper.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_ContentToClaimsMapper.go rename to pkg/service/providerindex/mock_ContentToClaimsMapper.go index 573aae3..7b96286 100644 --- a/pkg/internal/testutil/mocks/mock_ContentToClaimsMapper.go +++ b/pkg/service/providerindex/mock_ContentToClaimsMapper.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package providerindex import ( context "context" diff --git a/pkg/internal/testutil/mocks/mock_LegacyClaimsFinder.go b/pkg/service/providerindex/mock_LegacyClaimsFinder.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_LegacyClaimsFinder.go rename to pkg/service/providerindex/mock_LegacyClaimsFinder.go index 139a1c0..ab5a3d8 100644 --- a/pkg/internal/testutil/mocks/mock_LegacyClaimsFinder.go +++ b/pkg/service/providerindex/mock_LegacyClaimsFinder.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package providerindex import ( context "context" diff --git a/pkg/service/providerindex/providerindex_test.go b/pkg/service/providerindex/providerindex_test.go index edc8ac6..e4b9dd9 100644 --- a/pkg/service/providerindex/providerindex_test.go +++ b/pkg/service/providerindex/providerindex_test.go @@ -9,17 +9,17 @@ import ( "github.com/multiformats/go-multicodec" "github.com/storacha/go-metadata" "github.com/storacha/indexing-service/pkg/internal/testutil" - "github.com/storacha/indexing-service/pkg/internal/testutil/mocks" + "github.com/storacha/indexing-service/pkg/internal/testutil/extmocks" "github.com/storacha/indexing-service/pkg/types" "github.com/stretchr/testify/require" ) func TestGetProviderResults(t *testing.T) { t.Run("results found in the cache", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -37,10 +37,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("results not cached, found in IPNI, results cached afterwards", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -68,10 +68,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("results not cached, no results from IPNI, found in legacy claims service, results cached afterwards", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -92,10 +92,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("results not cached, IPNI returns uninteresting results, search in legacy claims", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -125,10 +125,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("returns an empty slice when results are not found anywhere, nothing gets cached", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -147,10 +147,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("error in cache returns error", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -165,10 +165,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("error fetching from IPNI returns an error", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -184,10 +184,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("error in legacy claims service returns an error", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) @@ -204,10 +204,10 @@ func TestGetProviderResults(t *testing.T) { }) t.Run("error caching results returns an error", func(t *testing.T) { - mockStore := mocks.NewMockProviderStore(t) - mockIpniFinder := mocks.NewMockFinder(t) - mockIpniPublisher := mocks.NewMockPublisher(t) - mockLegacyClaims := mocks.NewMockLegacyClaimsFinder(t) + mockStore := types.NewMockProviderStore(t) + mockIpniFinder := extmocks.NewMockIpniFinder(t) + mockIpniPublisher := extmocks.NewMockIpniPublisher(t) + mockLegacyClaims := NewMockLegacyClaimsFinder(t) providerIndex := New(mockStore, mockIpniFinder, mockIpniPublisher, mockLegacyClaims) diff --git a/pkg/internal/testutil/mocks/mock_ContentClaimsCache.go b/pkg/types/mock_ContentClaimsCache.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_ContentClaimsCache.go rename to pkg/types/mock_ContentClaimsCache.go index f526d00..6c85436 100644 --- a/pkg/internal/testutil/mocks/mock_ContentClaimsCache.go +++ b/pkg/types/mock_ContentClaimsCache.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package types import ( context "context" diff --git a/pkg/internal/testutil/mocks/mock_ContentClaimsStore.go b/pkg/types/mock_ContentClaimsStore.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_ContentClaimsStore.go rename to pkg/types/mock_ContentClaimsStore.go index 7d6227a..512bf7e 100644 --- a/pkg/internal/testutil/mocks/mock_ContentClaimsStore.go +++ b/pkg/types/mock_ContentClaimsStore.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package types import ( context "context" diff --git a/pkg/internal/testutil/mocks/mock_ProviderStore.go b/pkg/types/mock_ProviderStore.go similarity index 99% rename from pkg/internal/testutil/mocks/mock_ProviderStore.go rename to pkg/types/mock_ProviderStore.go index 010b461..ea7f68e 100644 --- a/pkg/internal/testutil/mocks/mock_ProviderStore.go +++ b/pkg/types/mock_ProviderStore.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.50.0. DO NOT EDIT. -package mocks +package types import ( context "context"