mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-11 11:08:38 -05:00
Tests of views on branches
This commit is contained in:
@@ -31,7 +31,7 @@ var ForeignKeyBranchTests = []queries.ScriptTest{
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "use mydb/b1",
|
||||
SkipResultsCheck: false,
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "SHOW CREATE TABLE child;",
|
||||
@@ -50,7 +50,7 @@ var ForeignKeyBranchTests = []queries.ScriptTest{
|
||||
},
|
||||
{
|
||||
Query: "use mydb/main",
|
||||
SkipResultsCheck: false,
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "SHOW CREATE TABLE child;",
|
||||
@@ -162,3 +162,63 @@ var ForeignKeyBranchTests = []queries.ScriptTest{
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var ViewBranchTests = []queries.ScriptTest{
|
||||
{
|
||||
Name: "create view on branch",
|
||||
SetUpScript: []string{
|
||||
"create table t1 (a int primary key, b int)",
|
||||
"insert into t1 values (1, 1), (2, 2), (3, 3)",
|
||||
"call dolt_commit('-Am', 'first commit')",
|
||||
"call dolt_branch('b1')",
|
||||
"use mydb/b1",
|
||||
"create view v1 as select * from t1 where a > 2",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "use mydb/b1",
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "select * from v1",
|
||||
Expected: []sql.Row{{3, 3}},
|
||||
},
|
||||
{
|
||||
Query: "use mydb/main",
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "select * from v1",
|
||||
ExpectedErr: sql.ErrTableNotFound,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "create view with no branch selected",
|
||||
SetUpScript: []string{
|
||||
"create table t1 (a int primary key, b int)",
|
||||
"insert into t1 values (1, 1), (2, 2), (3, 3)",
|
||||
"call dolt_commit('-Am', 'first commit')",
|
||||
"call dolt_branch('b1')",
|
||||
"create view `mydb/b1`.v1 as select * from t1 where a > 2",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "use mydb/b1",
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "select * from v1",
|
||||
Expected: []sql.Row{{3, 3}},
|
||||
},
|
||||
{
|
||||
Query: "use mydb/main",
|
||||
SkipResultsCheck: true,
|
||||
},
|
||||
{
|
||||
Query: "select * from v1",
|
||||
ExpectedErr: sql.ErrTableNotFound,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -965,6 +965,26 @@ func TestViews(t *testing.T) {
|
||||
enginetest.TestViews(t, h)
|
||||
}
|
||||
|
||||
func TestBranchViews(t *testing.T) {
|
||||
for _, script := range ViewBranchTests {
|
||||
func() {
|
||||
h := newDoltHarness(t)
|
||||
defer h.Close()
|
||||
enginetest.TestScript(t, h, script)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestBranchViewsPrepared(t *testing.T) {
|
||||
for _, script := range ViewBranchTests {
|
||||
func() {
|
||||
h := newDoltHarness(t)
|
||||
defer h.Close()
|
||||
enginetest.TestScriptPrepared(t, h, script)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionedViews(t *testing.T) {
|
||||
h := newDoltHarness(t)
|
||||
defer h.Close()
|
||||
|
||||
Reference in New Issue
Block a user