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
67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
package spanner
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/sqlc-dev/sqlc/internal/goldeneye/dialect"
|
|
"github.com/sqlc-dev/sqlc/internal/goldeneye/endtoend"
|
|
)
|
|
|
|
// TestDialect verifies the committed GoogleSQL dialect against what a
|
|
// Spanner server reports. It skips unless SPANNER_SERVER_URI names one.
|
|
func TestDialect(t *testing.T) {
|
|
endpoint, err := Locate()
|
|
if err != nil {
|
|
t.Skip(err)
|
|
}
|
|
ctx := context.Background()
|
|
version, err := Version(ctx, endpoint)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
files, err := Generate(ctx, endpoint)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
dir, err := dialect.Dir(Dir)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
report, err := dialect.Check(dir, files)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if report != "" {
|
|
t.Errorf("%s does not match what %s reports:\n%s", dir, version, report)
|
|
}
|
|
}
|
|
|
|
// TestAnalyzeCases verifies every GoogleSQL analyze case under
|
|
// internal/endtoend/testdata against what a Spanner server reports. It
|
|
// skips unless SPANNER_SERVER_URI names one.
|
|
func TestAnalyzeCases(t *testing.T) {
|
|
endpoint, err := Locate()
|
|
if err != nil {
|
|
t.Skip(err)
|
|
}
|
|
cases, err := endtoend.Cases(Cases)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(cases) == 0 {
|
|
t.Fatal("no googlesql analyze cases found")
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.Name, func(t *testing.T) {
|
|
diff, err := Check(context.Background(), endpoint, c)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if diff != "" {
|
|
t.Errorf("%s does not match what Spanner reports (-committed +spanner):\n%s", c.Output, diff)
|
|
}
|
|
})
|
|
}
|
|
}
|