Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feedback
  • Loading branch information
mjeffryes committed Dec 18, 2023
commit 8ae84199bfb45d4135308a2e60e00bc72480e4af
16 changes: 14 additions & 2 deletions tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package tests

import (
"bytes"
"fmt"
"io/fs"
"os"
Expand Down Expand Up @@ -124,8 +125,8 @@ func TestKubernetesVersionNodeJs(t *testing.T) {
// enter and build the generated package
withDir(t, path, func() {

require.NoError(t, exec.Command("npm", "i").Run())
require.NoError(t, exec.Command("npm", "run", "build").Run())
runRequireNoError(t, exec.Command("npm", "install"))
runRequireNoError(t, exec.Command("npm", "run", "build"))

// extract the version returned by a resource
appendFile(t, "bin/index.js", "\nconsole.log((new k8sversion.test.TestResource('test')).__version)")
Expand Down Expand Up @@ -157,3 +158,14 @@ func appendFile(t *testing.T, filename, content string) {

_, err = f.WriteString(content)
}

func runRequireNoError(t *testing.T, cmd *exec.Cmd) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you could also use https://pkg.go.dev/os/exec#Cmd.CombinedOutput to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks, I was looking for that, but didn't see it!

buf := new(bytes.Buffer)
cmd.Stdout = buf
cmd.Stderr = buf
err := cmd.Run()
if err != nil {
t.Log(buf)
}
require.NoError(t, err)
}