package ffdhall import ( "fmt" "testing" "time" "github.com/peterbourgon/ff/v3" "github.com/peterbourgon/ff/v3/fftest" ) func TestDhallParser(t *testing.T) { t.Parallel() for _, testcase := range []struct { name string args []string file string want fftest.Vars }{ { name: "empty input", args: []string{}, file: "testdata/empty.dhall", want: fftest.Vars{}, }, { name: "basic KV pairs", args: []string{}, file: "testdata/basic.dhall", want: fftest.Vars{S: "s", I: 10, B: true, D: 5 * time.Second}, }, { name: "value arrays", args: []string{}, file: "testdata/value_arrays.dhall", want: fftest.Vars{S: "bb", I: 12, B: true, D: 5 * time.Second, X: []string{"a", "B", "👍"}}, }, { name: "bad Dhall file", args: []string{}, file: "testdata/bad.dhall", want: fftest.Vars{WantParseErrorString: "no match found"}, }, } { t.Run(testcase.name, func(t *testing.T) { fs, vars := fftest.Pair() vars.ParseError = ff.Parse(fs, testcase.args, ff.WithConfigFile(testcase.file), ff.WithConfigFileParser(DhallParser), ) fmt.Println(vars.ParseError) fftest.Compare(t, &testcase.want, vars) }) } }