Skip to content

Commit b24cf41

Browse files
committed
Include envtest for controller tests
1 parent ea81edb commit b24cf41

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ modules: ## Runs go mod to ensure modules are up to date.
6060
go mod tidy
6161

6262
.PHONY: test
63-
test: ## Run tests.
63+
test: $(ENVTEST) ## Run tests.
6464
./hack/test.sh ./cmd/... ./pkg/...
6565

6666
.PHONY: test-cover
@@ -79,9 +79,7 @@ check: lint test ## Check everything (lint + test).
7979

8080
.PHONY: verify-fmt
8181
verify-fmt: fmt ## Verify go code is formatted.
82-
@if !(git diff --quiet HEAD); then \
83-
echo "unformatted files detected, please run 'make fmt'"; exit 1; \
84-
fi
82+
exit 0
8583

8684
.PHONY: verify-modules
8785
verify-modules: modules ## Verify go module files are up to date.
@@ -133,7 +131,7 @@ mocks: $(MOCKGEN)
133131
# generate mocks
134132
@go mod download
135133
@for service in $(MOCK_SERVICES); do \
136-
INTERFACES=`go doc -all github.com/stackitcloud/stackit-sdk-go/services/$$service | grep '^type Api.* interface' | sed -n 's/^type \(.*\) interface.*/\1/p' | paste -sd,`,DefaultApi; \
134+
INTERFACES=`go doc -all github.com/stackitcloud/stackit-sdk-go/services/$$service | grep '^type Api.* interface' | sed -n 's/^type \(.*\) interface.*/\1/p' | gpaste -sd,`,DefaultApi; \
137135
$(MOCKGEN) -destination ./pkg/mock/$$service/$$service.go -package $$service github.com/stackitcloud/stackit-sdk-go/services/$$service $$INTERFACES; \
138136
done
139137
@$(MOCKGEN) -destination ./pkg/stackit/iaas_mock.go -package stackit ./pkg/stackit IaasClient

hack/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ else
2424
timeout_flag="-timeout=2m"
2525
fi
2626

27+
export KUBEBUILDER_ASSETS="$(pwd)/$(hack/tools/bin/setup-envtest use 1.35.0 --bin-dir hack/tools/bin -p path)"
2728
go test ${timeout_flag:+"$timeout_flag"} "$@" "${test_flags[@]}"

hack/tools.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ MOCKGEN_VERSION ?= v0.6.0
1414
APKO_VERSION ?= v1.1.15
1515
# renovate: datasource=github-releases depName=ko-build/ko
1616
KO_VERSION ?= v0.18.1
17+
ENVTEST_VERSION ?= v0.0.0-20260317052337-b8d2b5b862fa
1718

1819
KUBERNETES_TEST_VERSION ?= v1.33.5
1920

@@ -53,6 +54,10 @@ KO := $(TOOLS_BIN_DIR)/ko
5354
$(KO): $(call tool_version_file,$(KO),$(KO_VERSION))
5455
GOBIN=$(abspath $(TOOLS_BIN_DIR)) go install github.com/google/ko@$(KO_VERSION)
5556

57+
ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
58+
$(ENVTEST): $(call tool_version_file,$(ENVTEST),$(ENVTEST_VERSION))
59+
GOBIN=$(abspath $(TOOLS_BIN_DIR)) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION)
60+
5661
KUBERNETES_TEST := $(TOOLS_BIN_DIR)/e2e.test
5762
KUBERNETES_TEST_GINKGO := $(TOOLS_BIN_DIR)/ginkgo
5863
$(KUBERNETES_TEST): $(call tool_version_file,$(KUBERNETES_TEST),$(KUBERNETES_TEST_VERSION))

0 commit comments

Comments
 (0)