When a stage is successful in a manifest v2, the success field is omitted from the result. In other words, the default value of the success field is true which is against the default value of boolean in Go. This commit implements a workaround. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
28 lines
561 B
Go
28 lines
561 B
Go
package osbuild2
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestStageResult_UnmarshalJSON(t *testing.T) {
|
|
cases := []struct {
|
|
input string
|
|
success bool
|
|
}{
|
|
{input: `{}`, success: true},
|
|
{input: `{"success": true}`, success: true},
|
|
{input: `{"success": false}`, success: false},
|
|
}
|
|
|
|
for _, c := range cases {
|
|
t.Run(c.input, func(t *testing.T) {
|
|
var result StageResult
|
|
err := json.Unmarshal([]byte(c.input), &result)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, c.success, result.Success)
|
|
})
|
|
}
|
|
}
|