Files
upstream-sqlc/internal/endtoend/ddl_test.go
upstream-mirror 0f4df23290
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
snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 02:17:34 +05:00

65 lines
1.2 KiB
Go

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)
}
})
}
}
}