Skip to content

Commit

Permalink
tests: Make testHelperCheckArtifacts flexible to qemu version used
Browse files Browse the repository at this point in the history
The file output may depend on the qemu version used. Match both cases so tests can be run on different series.

Signed-off-by: Paul Mars <[email protected]>
  • Loading branch information
upils committed Oct 16, 2024
1 parent 9f674ff commit 351748d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/statemachine/classic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3010,7 +3010,7 @@ func TestSuccessfulClassicRun(t *testing.T) {

artifacts := map[string]string{
"pc-amd64.img": "DOS/MBR boot sector",
"pc-amd64.qcow2": "QEMU QCOW2 Image (v3)",
"pc-amd64.qcow2": `QEMU QCOW2? Image \(v3\)`,
"filesystem-manifest.txt": "text",
"filesystem-filelist.txt": "text",
}
Expand Down Expand Up @@ -3171,7 +3171,10 @@ func testHelperCheckArtifacts(t *testing.T, asserter *helper.Asserter, outputDir
fileCommand := *exec.Command("file", fullPath)
cmdOutput, err := fileCommand.CombinedOutput()
asserter.AssertErrNil(err, true)
if !strings.Contains(string(cmdOutput), fileType) {

fileTypeRegex := regexp.MustCompile(fileType)

if !fileTypeRegex.Match([]byte(cmdOutput)) {
t.Errorf("File \"%s\" is the wrong file type. Expected \"%s\" but got \"%s\"",
fullPath, fileType, string(cmdOutput))
}
Expand Down

0 comments on commit 351748d

Please sign in to comment.