Skip to content

Commit

Permalink
STAC-22165: More output when script fails
Browse files Browse the repository at this point in the history
  • Loading branch information
craffit committed Dec 18, 2024
1 parent 3df586a commit 783b4e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions stable/suse-observability/test/install_scripts_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test

import (
"bytes"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -30,7 +31,7 @@ func TestChangeImageRepo(t *testing.T) {

tmpDir, err := os.MkdirTemp("/tmp", "install-scripts")
require.NoError(t, err)
// defer os.RemoveAll(tmpDir)
defer os.RemoveAll(tmpDir)

err = exec.Command("cp", "-a", filepath.Join(curDir, ".."), tmpDir).Run()
require.NoError(t, err)
Expand All @@ -55,6 +56,13 @@ func RunGetImagesScript(t *testing.T, dir string) string {
}

func RunChangeImageScript(t *testing.T, dir, registry, repository string) {
err := exec.Command(filepath.Join(dir, "maintenance", "change-image-source.sh"), "-g", registry, "-p", repository).Run()
cmd := exec.Command(filepath.Join(dir, "maintenance", "change-image-source.sh"), "-g", registry, "-p", repository)
var outb, errb bytes.Buffer
cmd.Stdout = &outb
cmd.Stderr = &errb
err := cmd.Run()
if err != nil {
t.Fatalf("Error running change-image-source.sh: %v\nstderr: %s\nstdout: %s", err, errb.String(), outb.String())
}
require.NoError(t, err)
}

0 comments on commit 783b4e8

Please sign in to comment.