Skip to content

Commit 1cf0a79

Browse files
committed
test: nitpicks
1 parent 0e471e9 commit 1cf0a79

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

test/e2e/e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var _ = Describe("GitHub Token Manager", Ordered, func() {
108108
cmd := exec.Command("ko", "build", "--local", "./cmd/manager")
109109
output, err := utils.Run(cmd)
110110
Expect(err).NotTo(HaveOccurred())
111-
projectImage = string(output)[:len(output)-1] // Remove newline
111+
projectImage = strings.TrimSpace(string(output))
112112

113113
if strings.HasPrefix(kubeContext, "kind-") {
114114
By("loading the manager image to Kind")

test/utils/utils.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package utils
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"crypto/rand"
2223
"crypto/rsa"
@@ -44,12 +45,21 @@ func Run(cmd *exec.Cmd) ([]byte, error) {
4445
cmd.Env = append(os.Environ(), "GO111MODULE=on")
4546
command := strings.Join(cmd.Args, " ")
4647
_, _ = fmt.Fprintf(ginkgo.GinkgoWriter, "running: %s\n", command)
47-
output, err := cmd.Output()
48+
49+
var stdout, stderr bytes.Buffer
50+
cmd.Stdout = &stdout
51+
cmd.Stderr = &stderr
52+
53+
err := cmd.Run()
4854
if err != nil {
49-
return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))
55+
stderrStr := stderr.String()
56+
if stderrStr != "" {
57+
return stdout.Bytes(), fmt.Errorf("%s failed with error: (%v) stderr: %s", command, err, stderrStr)
58+
}
59+
return stdout.Bytes(), fmt.Errorf("%s failed with error: (%v)", command, err)
5060
}
5161

52-
return output, nil
62+
return stdout.Bytes(), nil
5363
}
5464

5565
// LoadImageToKindCluster loads a local docker image to the kind cluster

0 commit comments

Comments
 (0)