Skip to content

Commit

Permalink
Putting all mocks into one directory (#951)
Browse files Browse the repository at this point in the history
related to #923,#932

I'm going to introduce new mocks for Manager and Client. I'm putting all mocks into one directory.

Signed-off-by: kuritka <kuritka@gmail.com>
  • Loading branch information
kuritka authored Sep 12, 2022
1 parent 68bb0c2 commit 7f9560b
Show file tree
Hide file tree
Showing 13 changed files with 620 additions and 67 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,13 @@ k8gb: lint
.PHONY: mocks
mocks:
go install github.com/golang/mock/mockgen@v1.5.0
mockgen -source=controllers/providers/assistant/assistant.go -destination=controllers/providers/assistant/assistant_mock.go -package=assistant
mockgen -source=controllers/providers/dns/dns.go -destination=controllers/providers/dns/dns_mock.go -package=dns
mockgen -source=controllers/providers/dns/infoblox-client.go -destination=controllers/providers/dns/infoblox-client_mock.go -package=dns
mockgen -source=controllers/depresolver/resolver.go -destination=controllers/depresolver/resolver_mock.go -package=depresolver
mockgen -destination=controllers/providers/dns/infoblox-connection_mock.go -package=dns github.com/infobloxopen/infoblox-go-client IBConnector
mockgen -package=mocks -destination=controllers/mocks/assistant_mock.go -source=controllers/providers/assistant/assistant.go Assistant
mockgen -package=mocks -destination=controllers/mocks/infoblox-client_mock.go -source=controllers/providers/dns/infoblox-client.go InfobloxClient
mockgen -package=mocks -destination=controllers/mocks/infoblox-connection_mock.go github.com/infobloxopen/infoblox-go-client IBConnector
mockgen -package=mocks -destination=controllers/mocks/manager_mock.go sigs.k8s.io/controller-runtime/pkg/manager Manager
mockgen -package=mocks -destination=controllers/mocks/client_mock.go sigs.k8s.io/controller-runtime/pkg/client Client
mockgen -package=mocks -destination=controllers/mocks/resolver_mock.go -source=controllers/depresolver/resolver.go GslbResolver
mockgen -package=mocks -destination=controllers/mocks/provider_mock.go -source=controllers/providers/dns/dns.go Provider
$(call golic)

# remove clusters and redeploy
Expand Down
8 changes: 4 additions & 4 deletions controllers/gslb_controller_reconciliation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ import (
"testing"
"time"

"github.com/golang/mock/gomock"

str "github.com/AbsaOSS/gopkg/string"
k8gbv1beta1 "github.com/k8gb-io/k8gb/api/v1beta1"
"github.com/k8gb-io/k8gb/controllers/depresolver"
"github.com/k8gb-io/k8gb/controllers/internal/utils"
"github.com/k8gb-io/k8gb/controllers/logging"
"github.com/k8gb-io/k8gb/controllers/mocks"
"github.com/k8gb-io/k8gb/controllers/providers/assistant"
"github.com/k8gb-io/k8gb/controllers/providers/dns"
"github.com/k8gb-io/k8gb/controllers/providers/metrics"
"github.com/k8gb-io/k8gb/controllers/tracing"

str "github.com/AbsaOSS/gopkg/string"
"github.com/golang/mock/gomock"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestGslbErrorsIncrement(t *testing.T) {
defer ctrl.Finish()
settings := provideSettings(t, predefinedConfig)
var label = prometheus.Labels{"namespace": settings.gslb.Namespace, "name": settings.gslb.Name}
m := dns.NewMockProvider(ctrl)
m := mocks.NewMockProvider(ctrl)
cnt := testutil.ToFloat64(metrics.Metrics().Get(metrics.K8gbGslbErrorsTotal).AsCounterVec().With(label))
m.EXPECT().GslbIngressExposedIPs(gomock.Any()).Return([]string{}, nil).Times(1)
m.EXPECT().SaveDNSEndpoint(gomock.Any(), gomock.Any()).Return(fmt.Errorf("save DNS error")).Times(1)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

227 changes: 227 additions & 0 deletions controllers/mocks/client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7f9560b

Please sign in to comment.