Skip to content

Commit ed0dc39

Browse files
jjomurali-reddy
authored andcommitted
[jjo] added network_services_controller ginkgo testing (#348)
* network services controller testing via moq and ginkgo * add network_services_test case for LoadBalancer w/o IPs * no-change-commit: glide.yaml: pin ginkgo and gomega versions, update only these in vendor/ * golint fixes * fixes from @andrewsykim review * group std imports
1 parent 4fd5cb8 commit ed0dc39

File tree

409 files changed

+36526
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+36526
-58
lines changed

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ kube-router:
3838
GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags '-X github.com/cloudnativelabs/kube-router/app.version=$(GIT_COMMIT) -X github.com/cloudnativelabs/kube-router/app.buildDate=$(BUILD_DATE)' -o kube-router kube-router.go
3939
@echo Finished kube-router binary build.
4040

41-
test: gofmt ## Runs code quality pipelines (gofmt, tests, coverage, lint, etc)
41+
test: gofmt gomoqs ## Runs code quality pipelines (gofmt, tests, coverage, lint, etc)
4242
go test github.com/cloudnativelabs/kube-router github.com/cloudnativelabs/kube-router/app/... github.com/cloudnativelabs/kube-router/utils/
4343

4444
vagrant-up: export docker=$(DOCKER)
@@ -127,6 +127,16 @@ gofmt: ## Tells you what files need to be gofmt'd.
127127
gofmt-fix: ## Fixes files that need to be gofmt'd.
128128
gofmt -s -w $(LOCAL_PACKAGES)
129129

130+
# List of all file_moq.go files which would need to be regenerated
131+
# from file.go if changed
132+
gomoqs: ./app/controllers/network_services_controller_moq.go
133+
134+
# file_moq.go file is generated from file.go "//go:generate moq ..." in-file
135+
# annotation, as it needs to know which interfaces to create mock stubs for
136+
%_moq.go: %.go
137+
@test -x $(GOPATH)/bin/moq && exit 0; echo "ERROR: 'moq' tool is needed to update mock test files, install it with: \ngo get github.com/matryer/moq\n"; exit 1
138+
go generate -v $(*).go
139+
130140
gopath: ## Warns about issues building from a directory that does not match upstream.
131141
@echo 'Checking project path for import issues...'
132142
@echo '- Project dir: $(MAKEFILE_DIR)'
@@ -205,7 +215,7 @@ ifeq (vagrant,$(firstword $(MAKECMDGOALS)))
205215
$(eval $(VAGRANT_RUN_ARGS):;@:)
206216
endif
207217

208-
.PHONY: build clean container run release goreleaser push gofmt gofmt-fix
218+
.PHONY: build clean container run release goreleaser push gofmt gofmt-fix gomoqs
209219
.PHONY: update-glide test docker-login push-release github-release help
210220
.PHONY: gopath gopath-fix vagrant-up-single-node
211221
.PHONY: vagrant-up-multi-node vagrant-destroy vagrant-clean vagrant
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package controllers_test
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
func TestControllers(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Controllers Suite")
13+
}

app/controllers/network_routes_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ func Test_addExportPolicies(t *testing.T) {
14181418
t.Errorf("failed to create existing nodes: %v", err)
14191419
}
14201420

1421+
// ClusterIPs and ExternalIPs
14211422
testcase.nrc.advertiseClusterIp = true
14221423
testcase.nrc.advertiseExternalIp = true
14231424
testcase.nrc.advertiseLoadBalancerIp = false

app/controllers/network_services_controller.go

Lines changed: 134 additions & 54 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)