Adding tests for revision DBs

This commit is contained in:
Jason Fulghum
2024-02-29 15:45:28 -08:00
parent 4e377157ff
commit 5859856fa3
@@ -784,6 +784,87 @@ var SchemaOverrideTests = []queries.ScriptTest{
},
},
// REVISION-DB TEST CASES
// TODO:
// `database/HEAD~`.`table`
// `database/tag`.`table`
// `database/commitHash`.`table` this one will be harder to test, because hash values can't be predicted
{
Name: "Revision DBs: branch revision database with overridden schema",
SetUpScript: []string{
"create table t (pk int primary key, c1 varchar(255));",
"insert into t (pk, c1) values (1, 'one');",
"call dolt_commit('-Am', 'adding table t on main');",
"call dolt_branch('branch1');",
"SET @commit1 = hashof('HEAD');",
"alter table t drop column c1;",
"call dolt_commit('-am', 'dropping column c1 on main');",
"call dolt_branch('branch2');",
"SET @commit2 = hashof('HEAD');",
"alter table t add column c2 varchar(255);",
"insert into t (pk, c2) values (2, 'two');",
"call dolt_commit('-am', 'adding column c2 on main');",
"call dolt_branch('branch3');",
"SET @commit3 = hashof('HEAD');",
},
Assertions: []queries.ScriptTestAssertion{
{
// use the most recent commit for our response schemas (pk, c2)
Query: "SET @@dolt_schema_override_commit=@commit3;",
Expected: []sql.Row{{}},
},
{
Query: "select * from `mydb/branch3`.t as of @commit1;",
Expected: []sql.Row{{1, nil}},
ExpectedColumns: sql.Schema{
{
Name: "pk",
Type: gmstypes.Int32,
},
{
Name: "c2",
Type: gmstypes.MustCreateStringWithDefaults(sqltypes.VarChar, 255),
},
},
},
{
// use the first commit from main for our response schemas (pk, c1)
Query: "SET @@dolt_schema_override_commit=@commit1;",
Expected: []sql.Row{{}},
},
{
Query: "select * from `mydb/branch3`.t as of @commit2;",
Expected: []sql.Row{{1, nil}},
ExpectedColumns: sql.Schema{
{
Name: "pk",
Type: gmstypes.Int32,
},
{
Name: "c1",
Type: gmstypes.MustCreateStringWithDefaults(sqltypes.VarChar, 255),
},
},
},
{
Query: "select * from `mydb/branch2`.t;",
Expected: []sql.Row{{1, nil}},
ExpectedColumns: sql.Schema{
{
Name: "pk",
Type: gmstypes.Int32,
},
{
Name: "c1",
Type: gmstypes.MustCreateStringWithDefaults(sqltypes.VarChar, 255),
},
},
},
},
},
// JOIN TEST CASES
{
Name: "Joins: Two tables with changed schemas",