* The tests in this file use txtar to define test input and expected output. This makes the JSON a lot easier to read vs. defining it in variables or structs with weird indentation. Tests begin by defining their JSON with: in, want := parseConfigTxtarTest(t, `an optional comment that will be log
(t *testing.T, test string)
| 28 | */ |
| 29 | |
| 30 | func parseConfigTxtarTest(t *testing.T, test string) (in *ConfigFile, want []byte) { |
| 31 | t.Helper() |
| 32 | |
| 33 | ar := txtar.Parse([]byte(test)) |
| 34 | if comment := strings.TrimSpace(string(ar.Comment)); comment != "" { |
| 35 | t.Log(comment) |
| 36 | } |
| 37 | for _, f := range ar.Files { |
| 38 | switch f.Name { |
| 39 | case "in": |
| 40 | var err error |
| 41 | in, err = LoadBytes(f.Data) |
| 42 | if err != nil { |
| 43 | t.Fatalf("input devbox.json is invalid: %v\n%s", err, f.Data) |
| 44 | } |
| 45 | |
| 46 | case "want": |
| 47 | want = f.Data |
| 48 | } |
| 49 | } |
| 50 | return in, want |
| 51 | } |
| 52 | |
| 53 | func optBytesToStrings() cmp.Option { |
| 54 | return cmp.Transformer("bytesToStrings", func(b []byte) string { |
no test coverage detected