Skip to content

Commit

Permalink
bake: fix testing json formatted output
Browse files Browse the repository at this point in the history
Because the test checked for combinedoutput, it
could contain internal warning messages in stderr.
JSON output is guaranteed in stdout.

Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Jul 9, 2024
1 parent 6807690 commit 0f74f9a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,15 +1074,16 @@ target "another" {
require.Contains(t, out, "another")
require.Contains(t, out, "UndefinedVar")

out, err = bakeCmd(
cmd := buildxCmd(
sb,
withDir(dir),
withArgs("build", "another", "--call", "check,format=json"),
withArgs("bake", "--progress=quiet", "build", "another", "--call", "check,format=json"),
)
require.Error(t, err, out)
outB, err := cmd.Output()
require.Error(t, err, string(outB))

var res map[string]any
err = json.Unmarshal([]byte(out), &res)
err = json.Unmarshal(outB, &res)
require.NoError(t, err, out)

targets, ok := res["target"].(map[string]any)
Expand Down

0 comments on commit 0f74f9a

Please sign in to comment.