From b479823994cd2da99586d4d954d7dfa9f14e8546 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 27 Aug 2021 15:02:27 -0700 Subject: [PATCH 1/3] add mock prefix --- Makefile | 6 ++++-- .../mockclients/{cnsclient.go => mock_cnsclient.go} | 0 .../mockclients/{kubeclient.go => mock_kubeclient.go} | 0 crd/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) rename cns/multitenantcontroller/mockclients/{cnsclient.go => mock_cnsclient.go} (100%) rename cns/multitenantcontroller/mockclients/{kubeclient.go => mock_kubeclient.go} (100%) diff --git a/Makefile b/Makefile index 879fd37396..38d35239cf 100644 --- a/Makefile +++ b/Makefile @@ -486,8 +486,10 @@ fmt format: $(GOFUMPT) ## run gofumpt on $FMT_PKG (default "cni cns npm") # run all tests .PHONY: test-all -test-all: - go test -tags "unit" -coverpkg=./... -v -race -covermode atomic -failfast -coverprofile=coverage.out ./... +test-all: + @$(eval CVPKG=`go list ./... | grep -v mock | tr '\n' ','`) + @echo Testing: $(CVPKG) + go test -tags "unit" -coverpkg=$(CVPKG) -v -race -covermode atomic -failfast -coverprofile=coverage.out ./... # run all tests diff --git a/cns/multitenantcontroller/mockclients/cnsclient.go b/cns/multitenantcontroller/mockclients/mock_cnsclient.go similarity index 100% rename from cns/multitenantcontroller/mockclients/cnsclient.go rename to cns/multitenantcontroller/mockclients/mock_cnsclient.go diff --git a/cns/multitenantcontroller/mockclients/kubeclient.go b/cns/multitenantcontroller/mockclients/mock_kubeclient.go similarity index 100% rename from cns/multitenantcontroller/mockclients/kubeclient.go rename to cns/multitenantcontroller/mockclients/mock_kubeclient.go diff --git a/crd/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go b/crd/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go index 802d57414d..149337830d 100644 --- a/crd/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go +++ b/crd/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go @@ -158,4 +158,4 @@ func (in *Scaler) DeepCopy() *Scaler { out := new(Scaler) in.DeepCopyInto(out) return out -} +} From 229fffbda37fd0f7d2975b60d07080ab931d4892 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Wed, 1 Sep 2021 16:37:22 -0700 Subject: [PATCH 2/3] generated suffix --- cns/multitenantcontroller/mockclients/Makefile | 6 +++--- .../{mock_cnsclient.go => cnsclient_generated.go} | 0 .../{mock_kubeclient.go => kubeclient_generated.go} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename cns/multitenantcontroller/mockclients/{mock_cnsclient.go => cnsclient_generated.go} (100%) rename cns/multitenantcontroller/mockclients/{mock_kubeclient.go => kubeclient_generated.go} (100%) diff --git a/cns/multitenantcontroller/mockclients/Makefile b/cns/multitenantcontroller/mockclients/Makefile index 866288e51c..8644ff2aba 100644 --- a/cns/multitenantcontroller/mockclients/Makefile +++ b/cns/multitenantcontroller/mockclients/Makefile @@ -6,9 +6,9 @@ MOCKGEN = $(TOOLS_BIN_DIR)/mockgen .PHONY: generate generate: $(MOCKGEN) ## Generate mock clients - $(MOCKGEN) -source=$(REPO_ROOT)/cns/cnsclient/apiclient.go -package=mockclients APIClient > cnsclient.go - $(MOCKGEN) -source=$(REPO_ROOT)/vendor/sigs.k8s.io/controller-runtime/pkg/client/interfaces.go -package=mockclients Client > kubeclient.go - @sed -i s,$(REPO_ROOT)/,,g cnsclient.go kubeclient.go + $(MOCKGEN) -source=$(REPO_ROOT)/cns/cnsclient/apiclient.go -package=mockclients APIClient > cnsclient_generated.go + $(MOCKGEN) -source=$(REPO_ROOT)/vendor/sigs.k8s.io/controller-runtime/pkg/client/interfaces.go -package=mockclients Client > kubeclient_generated.go + @sed -i s,$(REPO_ROOT)/,,g cnsclient_generated.go kubeclient_generated.go $(MOCKGEN): @make -C $(REPO_ROOT) $(MOCKGEN) diff --git a/cns/multitenantcontroller/mockclients/mock_cnsclient.go b/cns/multitenantcontroller/mockclients/cnsclient_generated.go similarity index 100% rename from cns/multitenantcontroller/mockclients/mock_cnsclient.go rename to cns/multitenantcontroller/mockclients/cnsclient_generated.go diff --git a/cns/multitenantcontroller/mockclients/mock_kubeclient.go b/cns/multitenantcontroller/mockclients/kubeclient_generated.go similarity index 100% rename from cns/multitenantcontroller/mockclients/mock_kubeclient.go rename to cns/multitenantcontroller/mockclients/kubeclient_generated.go From 8b1ab212ac2daeb8f662467b08edc0954f7a9f18 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Mon, 20 Sep 2021 18:32:43 -0700 Subject: [PATCH 3/3] add ignore tag --- cns/multitenantcontroller/mockclients/cnsclient_generated.go | 3 +++ cns/multitenantcontroller/mockclients/kubeclient_generated.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cns/multitenantcontroller/mockclients/cnsclient_generated.go b/cns/multitenantcontroller/mockclients/cnsclient_generated.go index a7eb4b00df..0069c6940a 100644 --- a/cns/multitenantcontroller/mockclients/cnsclient_generated.go +++ b/cns/multitenantcontroller/mockclients/cnsclient_generated.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Code generated by MockGen. DO NOT EDIT. // Source: cns/cnsclient/apiclient.go diff --git a/cns/multitenantcontroller/mockclients/kubeclient_generated.go b/cns/multitenantcontroller/mockclients/kubeclient_generated.go index 48638c20ef..464f29003f 100644 --- a/cns/multitenantcontroller/mockclients/kubeclient_generated.go +++ b/cns/multitenantcontroller/mockclients/kubeclient_generated.go @@ -1,3 +1,6 @@ +//go:build !ignore_uncovered +// +build !ignore_uncovered + // Code generated by MockGen. DO NOT EDIT. // Source: vendor/sigs.k8s.io/controller-runtime/pkg/client/interfaces.go