MCPcopy
hub / github.com/sqlc-dev/sqlc / TestBadConfigs

Function TestBadConfigs

internal/config/config_test.go:26–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24}`
25
26func TestBadConfigs(t *testing.T) {
27 for _, test := range []struct {
28 name string
29 err string
30 json string
31 }{
32 {
33 "missing version",
34 "no version number",
35 missingVersion,
36 },
37 {
38 "missing packages",
39 "no packages",
40 missingPackages,
41 },
42 {
43 "unknown version",
44 "invalid version number",
45 unknownVersion,
46 },
47 {
48 "unknown fields",
49 `yaml: unmarshal errors:
50 line 3: field foo not found in type config.V1GenerateSettings`,
51 unknownFields,
52 },
53 } {
54 tt := test
55 t.Run(tt.name, func(t *testing.T) {
56 _, err := ParseConfig(strings.NewReader(tt.json))
57 if err == nil {
58 t.Fatalf("expected err; got nil")
59 }
60 if diff := cmp.Diff(err.Error(), tt.err); diff != "" {
61 t.Errorf("differed (-want +got):\n%s", diff)
62 }
63 })
64 }
65}
66
67const validConfigOne = `{
68 "version": "1"

Callers

nothing calls this directly

Calls 2

ParseConfigFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected