Skip to content

Commit ac192bb

Browse files
committed
tests: friendly msg when go test is run with KUBEBUILDER_ASSETS missing
1 parent 59bc5b8 commit ac192bb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/client/client_venconn_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"net/http"
88
"net/http/httptest"
9+
"os"
910
"strings"
1011
"testing"
1112

@@ -334,6 +335,13 @@ func fakeTPP(t testing.TB) (*httptest.Server, *x509.Certificate) {
334335
//
335336
// export KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true
336337
func startEnvtest(t testing.TB) (_ *envtest.Environment, _ *rest.Config, kclient ctrlruntime.WithWatch) {
338+
// If KUBEBUILDER_ASSETS isn't set, show a warning to the user.
339+
if os.Getenv("KUBEBUILDER_ASSETS") == "" {
340+
t.Fatalf("KUBEBUILDER_ASSETS isn't set. You can run this test using `make test`.\n" +
341+
"But if you prefer not to use `make`, run these two commands first:\n" +
342+
" make _bin/tools/{kube-apiserver,etcd}\n" +
343+
" export KUBEBUILDER_ASSETS=$PWD/_bin/tools")
344+
}
337345
envtest := &envtest.Environment{
338346
ErrorIfCRDPathMissing: true,
339347
CRDDirectoryPaths: []string{"../../deploy/charts/venafi-kubernetes-agent/crd_bases/jetstack.io_venaficonnections.yaml"},

0 commit comments

Comments
 (0)