diff --git a/cmd/cuesonnet/main.go b/cmd/cuesonnet/main.go index 656baf09ddc2ca6e9391f1e4e5187952ecfb7c33..190f6585488e36cc8f782f0af4c6fb69480193ac 100644 --- a/cmd/cuesonnet/main.go +++ b/cmd/cuesonnet/main.go @@ -25,10 +25,6 @@ if err != nil { return fmt.Errorf("could not open data: %w", err) } - return cli(schema, data) -} - -func cli(schema, data []byte) error { var a any return cuesonnet.Schema(string(schema)).Decode(bytes.NewReader(data), &a) } diff --git a/cmd/cuesonnet/main_test.go b/cmd/cuesonnet/main_test.go deleted file mode 100644 index a63dbae04009809853cc0755a710baed3f7c0cd4..0000000000000000000000000000000000000000 --- a/cmd/cuesonnet/main_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import "testing" - -func TestCLI(t *testing.T) { - schema := `import "time" -#Schema: { - firstName: string - lastName: string - age: int - birthday: string - #Title: =~"^[A-Z]" | error("must start with an uppercase letter") - firstName: #Title - lastName: #Title - age: >0 - birthday: time.Format("01/02/2006") - gopher: bool | *true -} -` - data := `local name = 'Jim'; -local age = 45; - -local userData = function(name, age) { - firstName: name, - lastName: name + 'bly', - age: age, - birthday: '01/02/2003', -}; -` - - schemaSingle := schema + "#Schema" - dataSingle := data + "userData(name, age)" - if err := cli([]byte(schemaSingle), []byte(dataSingle)); err != nil { - t.Logf("single schema should match single data: %q", err) - t.FailNow() - } - - schemaList := schema + "[...#Schema]" - dataList := data + "[userData(name, age)]" - if err := cli([]byte(schemaList), []byte(dataList)); err != nil { - t.Logf("list schema should match list data: %q", err) - t.FailNow() - } -} diff --git a/cuesonnet_test.go b/cuesonnet_test.go index 8f52a14d70c2e021ca7763fc7ada029882651bb9..e867a77ca895f2f6e81a97c2e76e5bb86b7df6e3 100644 --- a/cuesonnet_test.go +++ b/cuesonnet_test.go @@ -11,8 +11,6 @@ var ( //go:embed testdata/schema.cue schema cuesonnet.Schema - //go:embed testdata/schema_list.cue - schemaList cuesonnet.Schema //go:embed testdata/config.jsonnet config string //go:embed testdata/almost-fixed.jsonnet @@ -21,8 +19,6 @@ //go:embed testdata/fixed.jsonnet fixed string //go:embed testdata/kitchen.jsonnet kitchen string - //go:embed testdata/kitchen_list.jsonnet - kitchenList string ) type Schema struct { @@ -52,7 +48,7 @@ var s Schema err := schema.Decode(strings.NewReader(almostFixed), &s) for _, s := range []string{"1", "LastName"} { if !strings.Contains(err.Error(), s) { - t.Logf("did not find %q in error: %q", s, err) + t.Logf("did not find %q in error", s) t.Fail() } } @@ -85,19 +81,6 @@ t.Logf("kitchen config should not fail to decode: %v", err) t.Fail() } if s != expect { - t.Logf("did not get expected decoding: %+v != %+v", s, expect) - t.Fail() - } - }) - - t.Run("list", func(t *testing.T) { - t.Parallel() - var s []Schema - if err := schemaList.Decode(strings.NewReader(kitchenList), &s); err != nil { - t.Logf("kitchen_list config should not fail to decode: %v", err) - t.Fail() - } - if s[0] != expect { t.Logf("did not get expected decoding: %+v != %+v", s, expect) t.Fail() } diff --git a/testdata/kitchen_list.jsonnet b/testdata/kitchen_list.jsonnet deleted file mode 100644 index 219bb98d348fcef47c974ea4dd36e4ec022c6b8e..0000000000000000000000000000000000000000 --- a/testdata/kitchen_list.jsonnet +++ /dev/null @@ -1,11 +0,0 @@ -local name = 'Jim'; -local age = 45; - -local userData = function(name, age) { - firstName: name, - lastName: name + 'bly', - age: age, - birthday: '01/02/2003', -}; - -[userData(name, age)] diff --git a/testdata/schema_list.cue b/testdata/schema_list.cue deleted file mode 100644 index 02024313163d96024bd64c4f01ef2dbd7e83b788..0000000000000000000000000000000000000000 --- a/testdata/schema_list.cue +++ /dev/null @@ -1,22 +0,0 @@ -import "time" - -#Schema: { - // Basic schema - firstName: string - lastName: string - age: int - birthday: string - - // Refine as needed - #Title: =~"^[A-Z]" | error("must start with an uppercase letter") - firstName: #Title - lastName: #Title - age: >0 - birthday: time.Format("01/02/2006") - - // Defaults - gopher: bool | *true -} - -// Apply the schema to root -[...#Schema]