diff --git a/load_test.go b/load_test.go index 7187eb78a..d172ae33f 100644 --- a/load_test.go +++ b/load_test.go @@ -1,6 +1,7 @@ package dalec import ( + _ "embed" "encoding/json" "errors" "fmt" @@ -9,6 +10,9 @@ import ( "testing" ) +//go:embed test/fixtures/unmarshall/source-inline.yml +var sourceInlineTemplate []byte + func TestSourceValidation(t *testing.T) { cases := []struct { title string @@ -334,29 +338,10 @@ func TestSourceFillDefaults(t *testing.T) { } func TestSourceInlineUnmarshalling(t *testing.T) { - yaml := ` -sources: - TestFileOctelPreGo113: - inline: - file: - contents: Hello world! - permissions: 0644 - TestFileOctelGo113: - inline: - file: - contents: Hello world! - permissions: 0o644 - TestDirOctelPreGo113: - inline: - dir: - permissions: 0755 - TestDirOctelGo113: - inline: - dir: - permissions: 0o755 -` - - spec, err := LoadSpec([]byte(yaml)) + // NOTE: not using text template yaml for this test + // tabs seem to be illegal in yaml indentation + // yaml unmarshalling with strict mode doesn't produce a great error message. + spec, err := LoadSpec(sourceInlineTemplate) if err != nil { t.Fatal(err) } diff --git a/test/fixtures/unmarshall/source-inline.yml b/test/fixtures/unmarshall/source-inline.yml new file mode 100644 index 000000000..0dfee532a --- /dev/null +++ b/test/fixtures/unmarshall/source-inline.yml @@ -0,0 +1,19 @@ +sources: + TestFileOctelPreGo113: + inline: + file: + contents: Hello world! + permissions: 0644 + TestFileOctelGo113: + inline: + file: + contents: Hello world! + permissions: 0o644 + TestDirOctelPreGo113: + inline: + dir: + permissions: 0755 + TestDirOctelGo113: + inline: + dir: + permissions: 0o755 \ No newline at end of file