-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathddl_test.go
More file actions
59 lines (50 loc) · 1.09 KB
/
ddl_test.go
File metadata and controls
59 lines (50 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/sqlc-dev/sqlc/internal/config"
"github.com/sqlc-dev/sqlc/internal/sqltest/local"
)
func TestValidSchema(t *testing.T) {
for _, replay := range FindTests(t, "testdata", "base") {
if replay.Exec != nil {
if replay.Exec.Meta.InvalidSchema {
continue
}
}
file := filepath.Join(replay.Path, replay.ConfigName)
rd, err := os.Open(file)
if err != nil {
t.Fatal(err)
}
conf, err := config.ParseConfig(rd)
if err != nil {
t.Fatal(err)
}
for j, pkg := range conf.SQL {
switch pkg.Engine {
case config.EnginePostgreSQL:
// pass
case config.EngineMySQL:
// pass
default:
continue
}
t.Run(fmt.Sprintf("endtoend-%s-%d", file, j), func(t *testing.T) {
t.Parallel()
var schema []string
for _, path := range pkg.Schema {
schema = append(schema, filepath.Join(filepath.Dir(file), path))
}
switch pkg.Engine {
case config.EnginePostgreSQL:
local.PostgreSQL(t, schema)
case config.EngineMySQL:
local.MySQL(t, schema)
}
})
}
}
}