Skip to content

Commit 5664224

Browse files
authored
test(endtoend): Split shema and queries (#2803)
* test(endtoend): Split schema and queries For all end-to-end tests, split the schema from the queries. This change makes it easier to load the expected schema into a database for validation and testing. * Remove workaround from ddl_test.go * Fix more tests
1 parent 8bb44b7 commit 5664224

File tree

1,541 files changed

+3288
-3202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,541 files changed

+3288
-3202
lines changed

internal/endtoend/ddl_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ func TestValidSchema(t *testing.T) {
9292
if err != nil {
9393
t.Fatalf("%s: %s", f, err)
9494
}
95-
// TODO: Split schema into separate files
96-
before, _, _ := strings.Cut(string(contents), "-- name:")
97-
before, _, _ = strings.Cut(before, "/* name:")
9895
// Support loading pg_dump SQL files
99-
before = strings.ReplaceAll(before, "CREATE SCHEMA public;", "CREATE SCHEMA IF NOT EXISTS public;")
96+
before := strings.ReplaceAll(string(contents), "CREATE SCHEMA public;", "CREATE SCHEMA IF NOT EXISTS public;")
10097
sqls = append(sqls, migrations.RemoveRollbackStatements(before))
10198
}
10299

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
CREATE TABLE bar (id serial not null);
2-
31
-- name: AliasBar :exec
42
DELETE FROM bar b
53
WHERE b.id = ?;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLE bar (id serial not null);
2+

internal/endtoend/testdata/alias/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"path": "go",
66
"engine": "mysql",
77
"name": "querytest",
8-
"schema": "query.sql",
8+
"schema": "schema.sql",
99
"queries": "query.sql"
1010
}
1111
]
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
CREATE TABLE bar (id serial not null);
2-
31
-- name: AliasBar :exec
42
DELETE FROM bar b
53
WHERE b.id = $1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLE bar (id serial not null);
2+

internal/endtoend/testdata/alias/postgresql/pgx/v4/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"engine": "postgresql",
77
"sql_package": "pgx/v4",
88
"name": "querytest",
9-
"schema": "query.sql",
9+
"schema": "schema.sql",
1010
"queries": "query.sql"
1111
}
1212
]
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
CREATE TABLE bar (id serial not null);
2-
31
-- name: AliasBar :exec
42
DELETE FROM bar b
53
WHERE b.id = $1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE TABLE bar (id serial not null);
2+

internal/endtoend/testdata/alias/postgresql/pgx/v5/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"engine": "postgresql",
77
"sql_package": "pgx/v5",
88
"name": "querytest",
9-
"schema": "query.sql",
9+
"schema": "schema.sql",
1010
"queries": "query.sql"
1111
}
1212
]

0 commit comments

Comments
 (0)