Skip to content

Commit

Permalink
switch inline test to use test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBrito authored and cpuguy83 committed Feb 16, 2024
1 parent 405d5c1 commit ac2a8cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
31 changes: 8 additions & 23 deletions load_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dalec

import (
_ "embed"
"encoding/json"
"errors"
"fmt"
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
19 changes: 19 additions & 0 deletions test/fixtures/unmarshall/source-inline.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ac2a8cc

Please sign in to comment.