Skip to content

Commit

Permalink
fix: added some additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Dec 22, 2023
1 parent 082e4af commit b0e2a41
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions internal/config/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ func TestLoadRefData(t *testing.T) {
},
wantErr: false,
},
{
name: "mapping node with ${include()}",
node: &yaml.Node{
Kind: yaml.ScalarNode,
Value: "${include(ref.yaml)}",
},
refContent: "key: value",
refFilename: "ref.yaml",
expected: &yaml.Node{
Kind: yaml.MappingNode,
Content: []*yaml.Node{
{Value: "key"},
{Value: "value"},
},
},
wantErr: false,
},
{
name: "mapping node with nested $ref",
node: &yaml.Node{
Expand Down Expand Up @@ -180,6 +197,17 @@ func TestLoadRefData(t *testing.T) {
expected: nil,
wantErr: true,
},
{
name: "error loading ref document with include",
node: &yaml.Node{
Kind: yaml.ScalarNode,
Content: []*yaml.Node{
{Value: "${include(ref.yaml)}"},
},
},
refContent: "key: value",
wantErr: true,
},
}

utils.FS = afero.NewMemMapFs()
Expand All @@ -199,10 +227,10 @@ func TestLoadRefData(t *testing.T) {
assert.Equal(t, filename, tc.refFilename)
assert.NoError(t, err)

expectedData := []byte{}
var expectedData []byte
require.NoError(t, tc.expected.Encode(expectedData))

resultData := []byte{}
var resultData []byte
require.NoError(t, tc.node.Encode(resultData))

assert.Equal(t, expectedData, resultData)
Expand Down

0 comments on commit b0e2a41

Please sign in to comment.