Skip to content

Commit 8652d26

Browse files
committed
fixup! test(e2e): Disable Calico tests (#1120)
Also handle empty output, and move panic to caller
1 parent 74076ab commit 8652d26

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

pkg/handlers/generic/lifecycle/ccm/nutanix/handler_test.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,21 @@ secretName: nutanix-ccm-credentials
5555
`
5656
)
5757

58-
var valuesTemplateFile = filepath.Join(
59-
moduleRootDir(),
60-
"charts",
61-
"cluster-api-runtime-extensions-nutanix",
62-
"addons",
63-
"ccm",
64-
"nutanix",
65-
"values-template.yaml",
66-
)
58+
var valuesTemplateFile = func() string {
59+
dir, err := moduleRootDir()
60+
if err != nil {
61+
panic(err)
62+
}
63+
return filepath.Join(
64+
dir,
65+
"charts",
66+
"cluster-api-runtime-extensions-nutanix",
67+
"addons",
68+
"ccm",
69+
"nutanix",
70+
"values-template.yaml",
71+
)
72+
}()
6773

6874
func Test_templateValues(t *testing.T) {
6975
t.Parallel()
@@ -194,20 +200,18 @@ func readCCMValuesTemplateFromProjectHelmChart(t *testing.T) string {
194200
return string(bs)
195201
}
196202

197-
func moduleRootDir() string {
203+
func moduleRootDir() (string, error) {
198204
cmd := exec.Command("go", "list", "-m", "-f", "{{ .Dir }}")
199205
out, err := cmd.CombinedOutput()
200-
if err != nil {
206+
if err != nil || len(out) == 0 {
201207
// We include the combined output because the error is usually
202208
// an exit code, which does not explain why the command failed.
203-
panic(
204-
fmt.Sprintf("cmd.Dir=%q, cmd.Env=%q, cmd.Args=%q, err=%q, output=%q",
205-
cmd.Dir,
206-
cmd.Env,
207-
cmd.Args,
208-
err,
209-
out),
210-
)
209+
return "", fmt.Errorf("cmd.Dir=%q, cmd.Env=%q, cmd.Args=%q, err=%q, output=%q",
210+
cmd.Dir,
211+
cmd.Env,
212+
cmd.Args,
213+
err,
214+
out)
211215
}
212216
// The first line is the module root directory. When go workspaces are used,
213217
// the first line is the "root" module root directory.

0 commit comments

Comments
 (0)