Skip to content

Commit

Permalink
Use marshalYAML instead of go-yaml
Browse files Browse the repository at this point in the history
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed May 21, 2024
1 parent 725703f commit 7a34464
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/limayaml/limayaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"testing"

"github.com/goccy/go-yaml"
"gotest.tools/v3/assert"
)

Expand All @@ -17,14 +16,6 @@ func dumpJSON(d interface{}) string {
return string(b)
}

func dumpYAML(d interface{}) string {
b, err := yaml.Marshal(d)
if err != nil {
return "ERROR"
}
return string(b)
}

const emptyYAML = "images: []\n"

const defaultYAML = "images: []\n"
Expand All @@ -34,11 +25,15 @@ func TestDefaultYAML(t *testing.T) {
assert.NilError(t, err)
var y LimaYAML
t.Log(dumpJSON(y))
assert.Equal(t, dumpYAML(y), emptyYAML)
b, err := marshalYAML(y)
assert.NilError(t, err)
assert.Equal(t, string(b), emptyYAML)
err = unmarshalYAML(bytes, &y, "")
assert.NilError(t, err)
y.Images = nil // remove default images
y.Mounts = nil // remove default mounts
t.Log(dumpJSON(y))
assert.Equal(t, dumpYAML(y), defaultYAML)
b, err = marshalYAML(y)
assert.NilError(t, err)
assert.Equal(t, string(b), defaultYAML)
}

0 comments on commit 7a34464

Please sign in to comment.