Skip to content

Commit

Permalink
Add basic unittest for limayaml validate
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 12, 2024
1 parent 1edd053 commit 462654d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/limayaml/validate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package limayaml

import (
"os"
"testing"

"gotest.tools/v3/assert"
)

func TestValidateEmpty(t *testing.T) {
y, err := Load([]byte{}, "empty.yaml")
assert.NilError(t, err)
err = Validate(y, false)
assert.Error(t, err, "field `images` must be set")
}

// Note: can't embed symbolic links, use "os"

func TestValidateDefault(t *testing.T) {
bytes, err := os.ReadFile("default.yaml")
assert.NilError(t, err)
y, err := Load(bytes, "default.yaml")
assert.NilError(t, err)
err = Validate(y, true)
assert.NilError(t, err)
}

0 comments on commit 462654d

Please sign in to comment.