snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
64
internal/endtoend/ddl_test.go
Normal file
64
internal/endtoend/ddl_test.go
Normal file
@@ -0,0 +1,64 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// Config-less command tests (parse, analyze) have no schema to validate.
|
||||
if replay.ConfigName == "" {
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user