More tests

This commit is contained in:
Zach Musgrave
2023-10-31 11:22:50 -07:00
parent ca07a92746
commit 3966913576

View File

@@ -4325,6 +4325,161 @@ var GeneratedColumnMergeTestScripts = []queries.ScriptTest{
},
},
},
{
Name: "merge a generated column created on another branch",
SetUpScript: []string{
"create table t1 (id bigint primary key, v1 bigint, v2 bigint)",
"insert into t1 (id, v1, v2) values (1, 1, 1), (2, 2, 2)",
"call dolt_commit('-Am', 'first commit')",
"call dolt_branch('branch1')",
"insert into t1 (id, v1, v2) values (3, 3, 3)",
"call dolt_commit('-Am', 'main commit')",
"call dolt_checkout('branch1')",
"alter table t1 add column v3 bigint as (v1 + v2) stored",
"alter table t1 add key idx_v3 (v3)",
"insert into t1 (id, v1, v2) values (4, 4, 4)",
"call dolt_commit('-Am', 'branch1 commit')",
"call dolt_checkout('main')",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "call dolt_merge('branch1')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
},
},
{
Query: "select id from t1 where v3 = 6",
Expected: []sql.Row{{3}},
},
{
Query: "call dolt_merge('branch2')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
{4, 4, 4, 8},
},
},
{
Query: "select id from t1 where v3 = 8",
Expected: []sql.Row{{4}},
},
},
},
{
Name: "merge a virtual column",
SetUpScript: []string{
"create table t1 (id bigint primary key, v1 bigint, v2 bigint, v3 bigint as (v1 + v2), index (v3))",
"insert into t1 (id, v1, v2) values (1, 1, 1), (2, 2, 2)",
"call dolt_commit('-Am', 'first commit')",
"call dolt_checkout('-b', 'branch1')",
"insert into t1 (id, v1, v2) values (3, 3, 3)",
"call dolt_commit('-Am', 'branch1 commit')",
"call dolt_checkout('main')",
"call dolt_checkout('-b', 'branch2')",
"insert into t1 (id, v1, v2) values (4, 4, 4)",
"call dolt_commit('-Am', 'branch2 commit')",
"call dolt_checkout('main')",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "call dolt_merge('branch1')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
},
},
{
Query: "select id from t1 where v3 = 6",
Expected: []sql.Row{{3}},
},
{
Query: "call dolt_merge('branch2')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
{4, 4, 4, 8},
},
},
{
Query: "select id from t1 where v3 = 8",
Expected: []sql.Row{{4}},
},
},
},
{
Name: "merge a virtual column created on another branch",
SetUpScript: []string{
"create table t1 (id bigint primary key, v1 bigint, v2 bigint)",
"insert into t1 (id, v1, v2) values (1, 1, 1), (2, 2, 2)",
"call dolt_commit('-Am', 'first commit')",
"call dolt_branch('branch1')",
"insert into t1 (id, v1, v2) values (3, 3, 3)",
"call dolt_commit('-Am', 'main commit')",
"call dolt_checkout('branch1')",
"alter table t1 add column v3 bigint as (v1 + v2)",
"alter table t1 add key idx_v3 (v3)",
"insert into t1 (id, v1, v2) values (4, 4, 4)",
"call dolt_commit('-Am', 'branch1 commit')",
"call dolt_checkout('main')",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "call dolt_merge('branch1')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
},
},
{
Query: "select id from t1 where v3 = 6",
Expected: []sql.Row{{3}},
},
{
Query: "call dolt_merge('branch2')",
SkipResultsCheck: true,
},
{
Query: "select * from t1 order by id",
Expected: []sql.Row{
{1, 1, 1, 2},
{2, 2, 2, 4},
{3, 3, 3, 6},
{4, 4, 4, 8},
},
},
{
Query: "select id from t1 where v3 = 8",
Expected: []sql.Row{{4}},
},
},
},
}
// convertMergeScriptTest converts a MergeScriptTest into a standard ScriptTest. If flipSides is true, then the