diff --git a/.bingo/README.md b/.bingo/README.md index 549760b..c812e3a 100644 --- a/.bingo/README.md +++ b/.bingo/README.md @@ -10,4 +10,4 @@ This is directory which stores Go modules with pinned buildable package that is ## Requirements -* Go 1.24.9 or later (see project CLAUDE.md for version requirements) +* Go 1.24.x or 1.25.x diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk index f2cbc3a..6547a7f 100644 --- a/.bingo/Variables.mk +++ b/.bingo/Variables.mk @@ -35,3 +35,9 @@ $(GOTESTSUM): $(BINGO_DIR)/gotestsum.mod @echo "(re)installing $(GOBIN)/gotestsum-v1.13.0" @cd $(BINGO_DIR) && GOWORK=off GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) GOARM=$(GOHOSTARM) $(GO) build -mod=mod -modfile=gotestsum.mod -o=$(GOBIN)/gotestsum-v1.13.0 "gotest.tools/gotestsum" +MOCKGEN := $(GOBIN)/mockgen-v0.6.0 +$(MOCKGEN): $(BINGO_DIR)/mockgen.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/mockgen-v0.6.0" + @cd $(BINGO_DIR) && GOWORK=off GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) GOARM=$(GOHOSTARM) $(GO) build -mod=mod -modfile=mockgen.mod -o=$(GOBIN)/mockgen-v0.6.0 "go.uber.org/mock/mockgen" + diff --git a/.bingo/mockgen.mod b/.bingo/mockgen.mod new file mode 100644 index 0000000..a0613ea --- /dev/null +++ b/.bingo/mockgen.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.25.0 + +require go.uber.org/mock v0.6.0 // mockgen diff --git a/.bingo/mockgen.sum b/.bingo/mockgen.sum new file mode 100644 index 0000000..8936eb9 --- /dev/null +++ b/.bingo/mockgen.sum @@ -0,0 +1,8 @@ +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= +golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= +golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= diff --git a/.bingo/variables.env b/.bingo/variables.env index de58482..e1ce49f 100644 --- a/.bingo/variables.env +++ b/.bingo/variables.env @@ -12,3 +12,5 @@ GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.64.8" GOTESTSUM="${GOBIN}/gotestsum-v1.13.0" +MOCKGEN="${GOBIN}/mockgen-v0.6.0" + diff --git a/.gitignore b/.gitignore index 32330e3..224220b 100755 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ secrets # Ignore generated OpenAPI code /pkg/api/openapi/ /data/generated/ + +# Ignore generated mock files +*_mock.go diff --git a/Makefile b/Makefile index 40c22c9..5e27aad 100755 --- a/Makefile +++ b/Makefile @@ -50,6 +50,8 @@ help: @echo "make test run unit tests" @echo "make test-integration run integration tests" @echo "make generate generate openapi modules" + @echo "make generate-mocks generate mock implementations for services" + @echo "make generate-all generate all code (openapi + mocks)" @echo "make clean delete temporary generated files" @echo "$(fake)" .PHONY: help @@ -121,13 +123,13 @@ lint: $(GOLANGCI_LINT) # Build binaries # NOTE it may be necessary to use CGO_ENABLED=0 for backwards compatibility with centos7 if not using centos7 -binary: check-gopath +binary: check-gopath generate-all echo "Building version: ${build_version}" CGO_ENABLED=$(CGO_ENABLED) GOEXPERIMENT=boringcrypto ${GO} build -ldflags="$(ldflags)" -o hyperfleet-api ./cmd/hyperfleet-api .PHONY: binary # Install -install: check-gopath +install: check-gopath generate-all CGO_ENABLED=$(CGO_ENABLED) GOEXPERIMENT=boringcrypto ${GO} install -ldflags="$(ldflags)" ./cmd/hyperfleet-api @ ${GO} version | grep -q "$(GO_VERSION)" || \ ( \ @@ -219,6 +221,15 @@ generate: $(container_tool) cp $(OPENAPI_IMAGE_ID):/local/data/generated/openapi/openapi.go ./data/generated/openapi/openapi.go .PHONY: generate +# Generate mock implementations for service interfaces +generate-mocks: $(MOCKGEN) + ${GO} generate ./pkg/services/... +.PHONY: generate-mocks + +# Generate all code (openapi + mocks) +generate-all: generate generate-mocks +.PHONY: generate-all + # Regenerate openapi client and models using vendor (avoids downloading dependencies) generate-vendor: rm -rf pkg/api/openapi diff --git a/go.mod b/go.mod index 63b5136..5ff3800 100755 --- a/go.mod +++ b/go.mod @@ -112,12 +112,15 @@ require ( go.opentelemetry.io/otel/metric v1.38.0 // indirect go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.uber.org/mock v0.6.0 // indirect golang.org/x/crypto v0.41.0 // indirect + golang.org/x/mod v0.27.0 // indirect golang.org/x/net v0.43.0 // indirect golang.org/x/sync v0.17.0 // indirect golang.org/x/sys v0.36.0 // indirect golang.org/x/text v0.29.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.36.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect google.golang.org/grpc v1.75.1 // indirect diff --git a/go.sum b/go.sum index dc5689a..6276544 100755 --- a/go.sum +++ b/go.sum @@ -632,6 +632,8 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -692,6 +694,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= +golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -894,6 +898,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= +golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/handlers/cluster_nodepools_test.go b/pkg/handlers/cluster_nodepools_test.go index 84a4c75..170fa36 100644 --- a/pkg/handlers/cluster_nodepools_test.go +++ b/pkg/handlers/cluster_nodepools_test.go @@ -1,7 +1,6 @@ package handlers import ( - "context" "encoding/json" "net/http" "net/http/httptest" @@ -10,6 +9,7 @@ import ( "github.com/gorilla/mux" . "github.com/onsi/gomega" + "go.uber.org/mock/gomock" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api/openapi" @@ -17,117 +17,6 @@ import ( "github.com/openshift-hyperfleet/hyperfleet-api/pkg/services" ) -// Mock ClusterService -type mockClusterService struct { - getFunc func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) -} - -func (m *mockClusterService) Get(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) { - if m.getFunc != nil { - return m.getFunc(ctx, id) - } - return nil, nil -} - -func (m *mockClusterService) Create(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError) { - return nil, nil -} - -func (m *mockClusterService) Replace(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError) { - return nil, nil -} - -func (m *mockClusterService) Delete(ctx context.Context, id string) *errors.ServiceError { - return nil -} - -func (m *mockClusterService) All(ctx context.Context) (api.ClusterList, *errors.ServiceError) { - return nil, nil -} - -func (m *mockClusterService) FindByIDs(ctx context.Context, ids []string) (api.ClusterList, *errors.ServiceError) { - return nil, nil -} - -func (m *mockClusterService) UpdateClusterStatusFromAdapters(ctx context.Context, clusterID string) (*api.Cluster, *errors.ServiceError) { - return nil, nil -} - -func (m *mockClusterService) OnUpsert(ctx context.Context, id string) error { - return nil -} - -func (m *mockClusterService) OnDelete(ctx context.Context, id string) error { - return nil -} - -// Mock NodePoolService -type mockNodePoolService struct { - getFunc func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) -} - -func (m *mockNodePoolService) Get(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) { - if m.getFunc != nil { - return m.getFunc(ctx, id) - } - return nil, nil -} - -func (m *mockNodePoolService) Create(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError) { - return nil, nil -} - -func (m *mockNodePoolService) Replace(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError) { - return nil, nil -} - -func (m *mockNodePoolService) Delete(ctx context.Context, id string) *errors.ServiceError { - return nil -} - -func (m *mockNodePoolService) All(ctx context.Context) (api.NodePoolList, *errors.ServiceError) { - return nil, nil -} - -func (m *mockNodePoolService) FindByIDs(ctx context.Context, ids []string) (api.NodePoolList, *errors.ServiceError) { - return nil, nil -} - -func (m *mockNodePoolService) UpdateNodePoolStatusFromAdapters(ctx context.Context, nodePoolID string) (*api.NodePool, *errors.ServiceError) { - return nil, nil -} - -func (m *mockNodePoolService) OnUpsert(ctx context.Context, id string) error { - return nil -} - -func (m *mockNodePoolService) OnDelete(ctx context.Context, id string) error { - return nil -} - -// Mock GenericService -type mockGenericService struct{} - -func (m *mockGenericService) Get(ctx context.Context, username string, id string, resource interface{}) *errors.ServiceError { - return nil -} - -func (m *mockGenericService) Create(ctx context.Context, username string, resource interface{}) *errors.ServiceError { - return nil -} - -func (m *mockGenericService) List(ctx context.Context, username string, listArgs *services.ListArguments, resources interface{}) (*api.PagingMeta, *errors.ServiceError) { - return nil, nil -} - -func (m *mockGenericService) Update(ctx context.Context, username string, resource interface{}) *errors.ServiceError { - return nil -} - -func (m *mockGenericService) Delete(ctx context.Context, username string, resource interface{}) *errors.ServiceError { - return nil -} - func TestClusterNodePoolsHandler_Get(t *testing.T) { RegisterTestingT(t) @@ -139,8 +28,7 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { name string clusterID string nodePoolID string - mockClusterFunc func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) - mockNodePoolFunc func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) + setupMocks func(ctrl *gomock.Controller) (*services.MockClusterService, *services.MockNodePoolService, *services.MockGenericService) expectedStatusCode int expectedError bool }{ @@ -148,18 +36,21 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { name: "Success - Get nodepool by cluster and nodepool ID", clusterID: clusterID, nodePoolID: nodePoolID, - mockClusterFunc: func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) { - return &api.Cluster{ + setupMocks: func(ctrl *gomock.Controller) (*services.MockClusterService, *services.MockNodePoolService, *services.MockGenericService) { + mockClusterSvc := services.NewMockClusterService(ctrl) + mockNodePoolSvc := services.NewMockNodePoolService(ctrl) + mockGenericSvc := services.NewMockGenericService(ctrl) + + mockClusterSvc.EXPECT().Get(gomock.Any(), clusterID).Return(&api.Cluster{ Meta: api.Meta{ ID: clusterID, CreatedTime: now, UpdatedTime: now, }, Name: "test-cluster", - }, nil - }, - mockNodePoolFunc: func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) { - return &api.NodePool{ + }, nil) + + mockNodePoolSvc.EXPECT().Get(gomock.Any(), nodePoolID).Return(&api.NodePool{ Meta: api.Meta{ ID: nodePoolID, CreatedTime: now, @@ -168,7 +59,9 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { Kind: "NodePool", Name: "test-nodepool", OwnerID: clusterID, - }, nil + }, nil) + + return mockClusterSvc, mockNodePoolSvc, mockGenericSvc }, expectedStatusCode: http.StatusOK, expectedError: false, @@ -177,11 +70,14 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { name: "Error - Cluster not found", clusterID: "non-existent", nodePoolID: nodePoolID, - mockClusterFunc: func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) { - return nil, errors.NotFound("Cluster not found") - }, - mockNodePoolFunc: func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) { - return nil, nil + setupMocks: func(ctrl *gomock.Controller) (*services.MockClusterService, *services.MockNodePoolService, *services.MockGenericService) { + mockClusterSvc := services.NewMockClusterService(ctrl) + mockNodePoolSvc := services.NewMockNodePoolService(ctrl) + mockGenericSvc := services.NewMockGenericService(ctrl) + + mockClusterSvc.EXPECT().Get(gomock.Any(), "non-existent").Return(nil, errors.NotFound("Cluster not found")) + + return mockClusterSvc, mockNodePoolSvc, mockGenericSvc }, expectedStatusCode: http.StatusNotFound, expectedError: true, @@ -190,18 +86,23 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { name: "Error - NodePool not found", clusterID: clusterID, nodePoolID: "non-existent", - mockClusterFunc: func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) { - return &api.Cluster{ + setupMocks: func(ctrl *gomock.Controller) (*services.MockClusterService, *services.MockNodePoolService, *services.MockGenericService) { + mockClusterSvc := services.NewMockClusterService(ctrl) + mockNodePoolSvc := services.NewMockNodePoolService(ctrl) + mockGenericSvc := services.NewMockGenericService(ctrl) + + mockClusterSvc.EXPECT().Get(gomock.Any(), clusterID).Return(&api.Cluster{ Meta: api.Meta{ ID: clusterID, CreatedTime: now, UpdatedTime: now, }, Name: "test-cluster", - }, nil - }, - mockNodePoolFunc: func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) { - return nil, errors.NotFound("NodePool not found") + }, nil) + + mockNodePoolSvc.EXPECT().Get(gomock.Any(), "non-existent").Return(nil, errors.NotFound("NodePool not found")) + + return mockClusterSvc, mockNodePoolSvc, mockGenericSvc }, expectedStatusCode: http.StatusNotFound, expectedError: true, @@ -210,18 +111,21 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { name: "Error - NodePool belongs to different cluster", clusterID: clusterID, nodePoolID: nodePoolID, - mockClusterFunc: func(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) { - return &api.Cluster{ + setupMocks: func(ctrl *gomock.Controller) (*services.MockClusterService, *services.MockNodePoolService, *services.MockGenericService) { + mockClusterSvc := services.NewMockClusterService(ctrl) + mockNodePoolSvc := services.NewMockNodePoolService(ctrl) + mockGenericSvc := services.NewMockGenericService(ctrl) + + mockClusterSvc.EXPECT().Get(gomock.Any(), clusterID).Return(&api.Cluster{ Meta: api.Meta{ ID: clusterID, CreatedTime: now, UpdatedTime: now, }, Name: "test-cluster", - }, nil - }, - mockNodePoolFunc: func(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) { - return &api.NodePool{ + }, nil) + + mockNodePoolSvc.EXPECT().Get(gomock.Any(), nodePoolID).Return(&api.NodePool{ Meta: api.Meta{ ID: nodePoolID, CreatedTime: now, @@ -230,7 +134,9 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { Kind: "NodePool", Name: "test-nodepool", OwnerID: "different-cluster-789", // Different cluster - }, nil + }, nil) + + return mockClusterSvc, mockNodePoolSvc, mockGenericSvc }, expectedStatusCode: http.StatusNotFound, expectedError: true, @@ -241,10 +147,12 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { t.Run(tt.name, func(t *testing.T) { RegisterTestingT(t) - // Create mock services - mockClusterSvc := &mockClusterService{getFunc: tt.mockClusterFunc} - mockNodePoolSvc := &mockNodePoolService{getFunc: tt.mockNodePoolFunc} - mockGenericSvc := &mockGenericService{} + // Create gomock controller + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Setup mocks + mockClusterSvc, mockNodePoolSvc, mockGenericSvc := tt.setupMocks(ctrl) // Create handler handler := NewClusterNodePoolsHandler(mockClusterSvc, mockNodePoolSvc, mockGenericSvc) diff --git a/pkg/services/adapter_status.go b/pkg/services/adapter_status.go index 7b56446..e496be5 100644 --- a/pkg/services/adapter_status.go +++ b/pkg/services/adapter_status.go @@ -8,6 +8,8 @@ import ( "github.com/openshift-hyperfleet/hyperfleet-api/pkg/errors" ) +//go:generate mockgen-v0.6.0 -source=adapter_status.go -package=services -destination=adapter_status_mock.go + type AdapterStatusService interface { Get(ctx context.Context, id string) (*api.AdapterStatus, *errors.ServiceError) Create(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError) diff --git a/pkg/services/cluster.go b/pkg/services/cluster.go index 4a8371f..629b788 100644 --- a/pkg/services/cluster.go +++ b/pkg/services/cluster.go @@ -12,6 +12,8 @@ import ( "github.com/openshift-hyperfleet/hyperfleet-api/pkg/logger" ) +//go:generate mockgen-v0.6.0 -source=cluster.go -package=services -destination=cluster_mock.go + type ClusterService interface { Get(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError) Create(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError) diff --git a/pkg/services/generic.go b/pkg/services/generic.go index 79917d3..eca9cca 100755 --- a/pkg/services/generic.go +++ b/pkg/services/generic.go @@ -21,6 +21,8 @@ import ( "github.com/openshift-hyperfleet/hyperfleet-api/pkg/logger" ) +//go:generate mockgen-v0.6.0 -source=generic.go -package=services -destination=generic_mock.go + type GenericService interface { List(ctx context.Context, username string, args *ListArguments, resourceList interface{}) (*api.PagingMeta, *errors.ServiceError) } diff --git a/pkg/services/node_pool.go b/pkg/services/node_pool.go index 9fa1336..1403f84 100644 --- a/pkg/services/node_pool.go +++ b/pkg/services/node_pool.go @@ -12,6 +12,8 @@ import ( "github.com/openshift-hyperfleet/hyperfleet-api/pkg/logger" ) +//go:generate mockgen-v0.6.0 -source=node_pool.go -package=services -destination=node_pool_mock.go + type NodePoolService interface { Get(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError) Create(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError)