Skip to content

Commit 1d5cfe9

Browse files
committed
Add some unit test cases for the yaml load
Signed-off-by: Anders F Björklund <[email protected]>
1 parent 235494a commit 1d5cfe9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg/limayaml/load_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package limayaml
2+
3+
import (
4+
"testing"
5+
6+
"gotest.tools/v3/assert"
7+
)
8+
9+
func TestLoadEmpty(t *testing.T) {
10+
_, err := Load([]byte{}, "empty.yaml")
11+
assert.NilError(t, err)
12+
}
13+
14+
func TestLoadError(t *testing.T) {
15+
// missing a "script:" line
16+
s := `
17+
provision:
18+
- mode: system
19+
script: |
20+
#!/bin/sh
21+
echo one
22+
- mode: system
23+
#!/bin/sh
24+
echo two
25+
- mode: system
26+
script: |
27+
#!/bin/sh
28+
echo three
29+
`
30+
_, err := Load([]byte(s), "error.yaml")
31+
assert.ErrorContains(t, err, "failed to unmarshal YAML")
32+
}

0 commit comments

Comments
 (0)