Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for branch interactions with schema #644

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions testing/go/schemas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,109 @@ var SchemaTests = []ScriptTest{
},
},
},
{
Name: "with branches",
SetUpScript: []string{
"CREATE SCHEMA myschema",
"SET search_path = 'myschema'",
"CREATE TABLE mytbl (pk BIGINT PRIMARY KEY, v1 BIGINT);",
},
Assertions: []ScriptTestAssertion{
{
Query: "SELECT active_branch();",
Expected: []sql.Row{{"main"}},
},
{
Query: "SELECT current_schemas(true);",
Expected: []sql.Row{
{"{pg_catalog,myschema}"},
},
},
{
Skip: true, // TODO: revision database not supported yet
Query: "SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'postgres/main';",
Expected: []sql.Row{
{"myschema"},
{"pg_catalog"},
{"public"},
{"information_schema"},
},
},
{
Query: "SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'postgres';",
Expected: []sql.Row{
{"myschema"},
{"pg_catalog"},
{"public"},
{"information_schema"},
},
},
{
Query: "SELECT * FROM mytbl;",
Expected: []sql.Row{},
},
{
Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog';",
Expected: []sql.Row{
{"myschema", "mytbl"},
},
},
{
Query: "SELECT dolt_checkout('-b', 'newbranch')",
Expected: []sql.Row{{"{0,\"Switched to branch 'newbranch'\"}"}},
},
{
Skip: true, // TODO: ERROR: no schema has been selected to create in
Query: "CREATE TABLE mytbl2 (pk BIGINT PRIMARY KEY, v1 BIGINT);",
Expected: []sql.Row{},
},
{
Query: "CREATE SCHEMA newbranchschema;",
Expected: []sql.Row{},
},
{
Query: "SET search_path = 'newbranchschema';",
Expected: []sql.Row{},
},
{
Query: "CREATE TABLE mytbl2 (pk BIGINT PRIMARY KEY, v1 BIGINT);",
Expected: []sql.Row{},
},
{
Query: "SELECT current_schemas(true)",
Expected: []sql.Row{
{"{pg_catalog,newbranchschema}"},
},
},
{
Skip: true, // TODO: revision database not supported yet
Query: "SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'postgres/newbranch';",
Expected: []sql.Row{
{"newbranchschema"},
{"pg_catalog"},
{"public"},
{"information_schema"},
},
},
{
Skip: true, // TODO: Why are pg_catalog and public not showing up?
Query: "SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'postgres';",
Expected: []sql.Row{
{"newbranchschema"},
{"pg_catalog"},
{"public"},
{"information_schema"},
},
},
{
Skip: true, // TODO: Getting error "database schema not found: pg_catalog"
Query: "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog';",
Expected: []sql.Row{
{"newbranchschema", "mytbl2"},
},
},
},
},
// More tests:
// * alter table statements, when they work better
// * AS OF (when supported)
Expand Down
Loading