MCPcopy Create free account
hub / github.com/jetify-com/devbox / parseConfigTxtarTest

Function parseConfigTxtarTest

internal/devconfig/configfile/file_test.go:30–51  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

28*/
29
30func 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
53func optBytesToStrings() cmp.Option {
54 return cmp.Transformer("bytesToStrings", func(b []byte) string {

Callers 15

TestNoChangesFunction · 0.85
TestAddPackageNullFunction · 0.85
TestAddPackageObjectFunction · 0.85
TestAddPackageEmptyArrayFunction · 0.85
TestRemovePackageObjectFunction · 0.85

Calls 1

LoadBytesFunction · 0.85

Tested by

no test coverage detected