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

Function TestValidSchema

internal/endtoend/ddl_test.go:13–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestValidSchema(t *testing.T) {
14 for _, replay := range FindTests(t, "testdata", "base") {
15 replay := replay // https://golang.org/doc/faq#closures_and_goroutines
16
17 if replay.Exec != nil {
18 if replay.Exec.Meta.InvalidSchema {
19 continue
20 }
21 }
22
23 file := filepath.Join(replay.Path, replay.ConfigName)
24 rd, err := os.Open(file)
25 if err != nil {
26 t.Fatal(err)
27 }
28
29 conf, err := config.ParseConfig(rd)
30 if err != nil {
31 t.Fatal(err)
32 }
33
34 for j, pkg := range conf.SQL {
35 j, pkg := j, pkg
36 switch pkg.Engine {
37 case config.EnginePostgreSQL:
38 // pass
39 case config.EngineMySQL:
40 // pass
41 default:
42 continue
43 }
44 t.Run(fmt.Sprintf("endtoend-%s-%d", file, j), func(t *testing.T) {
45 t.Parallel()
46
47 var schema []string
48 for _, path := range pkg.Schema {
49 schema = append(schema, filepath.Join(filepath.Dir(file), path))
50 }
51
52 switch pkg.Engine {
53 case config.EnginePostgreSQL:
54 local.PostgreSQL(t, schema)
55 case config.EngineMySQL:
56 local.MySQL(t, schema)
57 }
58 })
59 }
60 }
61}

Callers

nothing calls this directly

Calls 6

ParseConfigFunction · 0.92
PostgreSQLFunction · 0.92
MySQLFunction · 0.92
FindTestsFunction · 0.85
OpenMethod · 0.80
JoinMethod · 0.45

Tested by

no test coverage detected