Fix failing tests

This commit is contained in:
Tan Yong Zhi
2022-08-20 23:40:18 +08:00
parent f810da5062
commit 7dd5d6b4d6
5 changed files with 27 additions and 0 deletions

View File

@@ -96,9 +96,11 @@ func TestMerge(t *testing.T) {
{cmd.BranchCmd{}, args{"other"}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk varchar(120) primary key);"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES ('a'),('b'),('c');"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added rows on main"}},
{cmd.CheckoutCmd{}, args{"other"}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk varchar(120) primary key);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES ('x'),('y'),('z');"}},
{cmd.CommitCmd{}, args{"-am", "added rows on other"}},
{cmd.CheckoutCmd{}, args{env.DefaultInitBranch}},
@@ -145,6 +147,7 @@ func TestMergeConflicts(t *testing.T) {
setupCommon := []testCommand{
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE test (pk int PRIMARY KEY, c0 int);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "created table test"}},
}
@@ -176,6 +179,7 @@ func TestMergeConflicts(t *testing.T) {
setup: []testCommand{
{cmd.CheckoutCmd{}, args{"-b", "other"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO test VALUES (1,1),(2,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added rows on other"}},
{cmd.CheckoutCmd{}, args{env.DefaultInitBranch}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO test VALUES (1,11),(2,22);"}},
@@ -195,10 +199,12 @@ func TestMergeConflicts(t *testing.T) {
{cmd.CheckoutCmd{}, args{"-b", "other"}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk int PRIMARY KEY, c0 int);"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES (1,1),(2,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added rows on other"}},
{cmd.CheckoutCmd{}, args{env.DefaultInitBranch}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk int PRIMARY KEY, c0 int);"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES (1,11),(2,22);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added the same rows on main"}},
{cmd.MergeCmd{}, args{"other"}},
},
@@ -213,10 +219,12 @@ func TestMergeConflicts(t *testing.T) {
{cmd.CheckoutCmd{}, args{"-b", "other"}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk int PRIMARY KEY, c0 int);"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES (1,1),(2,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added rows on other"}},
{cmd.CheckoutCmd{}, args{env.DefaultInitBranch}},
{cmd.SqlCmd{}, args{"-q", "CREATE TABLE quiz (pk int PRIMARY KEY, c0 int);"}},
{cmd.SqlCmd{}, args{"-q", "INSERT INTO quiz VALUES (1,11),(2,22);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, args{"-am", "added the same rows on main"}},
{cmd.MergeCmd{}, args{"other"}},
{cnfcmds.ResolveCmd{}, args{"--theirs", "quiz"}},

View File

@@ -47,6 +47,7 @@ func TestKeylessMerge(t *testing.T) {
name: "fast-forward merge",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (3,4);"}},
@@ -63,6 +64,7 @@ func TestKeylessMerge(t *testing.T) {
name: "3-way merge",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (3,4);"}},
@@ -82,6 +84,7 @@ func TestKeylessMerge(t *testing.T) {
name: "3-way merge with duplicates",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (3,4), (3,4);"}},
@@ -145,6 +148,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
name: "identical parallel changes",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (3,4);"}},
@@ -174,6 +178,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
name: "asymmetric parallel deletes",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2),(1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "delete from noKey where (c1,c2) = (1,2) limit 1;"}},
@@ -201,6 +206,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
name: "asymmetric parallel updates",
setup: []testCommand{
{cmd.SqlCmd{}, []string{"-q", "insert into noKey values (1,2),(1,2),(1,2),(1,2);"}},
{cmd.AddCmd{}, []string{"."}},
{cmd.CommitCmd{}, []string{"-am", "added rows"}},
{cmd.CheckoutCmd{}, []string{"-b", "other"}},
{cmd.SqlCmd{}, []string{"-q", "update noKey set c2 = 9 limit 1;"}},

View File

@@ -11,6 +11,7 @@ setup() {
dolt init
dolt tag v1
dolt sql -q "create table t1 (a int)"
dolt add .
dolt commit -am "cm"
dolt branch feature
dolt remote add origin file://../rem1
@@ -187,6 +188,7 @@ teardown() {
cd .. && mkdir repo2 && cd repo2
dolt init
dolt sql -q "create table s1 (a int)"
dolt add .
dolt commit -am "cm"
dolt backup add bac1 file://../bac1

View File

@@ -5,6 +5,7 @@ setup() {
setup_common
dolt sql -q "CREATE TABLE test(pk BIGINT PRIMARY KEY, v varchar(10))"
dolt add .
dolt commit -am "Created table"
dolt checkout -b branch1
dolt sql -q "INSERT INTO test VALUES (1, 'a')"
@@ -103,6 +104,7 @@ teardown() {
@test "cherry-pick: insert, update, delete rows and schema changes on non existent table in working set" {
dolt sql -q "CREATE TABLE branch1table (id int primary key, col1 int)"
dolt add .
dolt sql -q "INSERT INTO branch1table VALUES (9,8),(7,6),(5,4)"
dolt commit -am "create table with rows"
@@ -156,12 +158,14 @@ teardown() {
@test "cherry-pick: row data conflict, leave working set clean" {
dolt sql -q "CREATE TABLE other (pk int primary key, v int)"
dolt add .
dolt sql -q "INSERT INTO other VALUES (1, 2)"
dolt sql -q "INSERT INTO test VALUES (4,'f')"
dolt commit -am "add other table"
dolt checkout main
dolt sql -q "CREATE TABLE other (pk int primary key, v int)"
dolt add .
dolt sql -q "INSERT INTO other VALUES (1, 3)"
dolt sql -q "INSERT INTO test VALUES (4,'k')"
dolt commit -am "add other table with conflict and test with conflict"
@@ -176,6 +180,7 @@ teardown() {
@test "cherry-pick: commit with CREATE TABLE" {
dolt sql -q "CREATE TABLE table_a (pk BIGINT PRIMARY KEY, v varchar(10))"
dolt add .
dolt sql -q "INSERT INTO table_a VALUES (11, 'aa'), (22, 'ab'), (33, 'ac')"
dolt sql -q "DELETE FROM test WHERE pk = 2"
dolt commit -am "Added table_a with rows and delete pk=2 from test"
@@ -220,6 +225,7 @@ teardown() {
@test "cherry-pick: commit with ALTER TABLE rename table name" {
dolt sql -q "ALTER TABLE test RENAME TO new_name"
dolt add .
dolt commit -am "rename table name"
dolt checkout main
@@ -274,6 +280,7 @@ teardown() {
run dolt sql -q "SELECT * FROM test"
[[ "$output" =~ "z inserted" ]] || false
dolt add .
dolt commit -am "add trigger"
dolt checkout main
@@ -305,6 +312,7 @@ teardown() {
run dolt sql -q "CALL proc1(434)"
[[ "$output" =~ "434" ]] || false
dolt add .
dolt commit -am "add procedure"
dolt checkout main
@@ -324,6 +332,7 @@ teardown() {
@test "cherry-pick: keyless table" {
dolt checkout main
dolt sql -q "CREATE TABLE keyless (id int, name varchar(10))"
dolt add .
dolt commit -am "add keyless table"
dolt checkout -b branch2

View File

@@ -11,6 +11,7 @@ CREATE TABLE keyless (
);
INSERT INTO keyless VALUES (0,0),(2,2),(1,1),(1,1);
SQL
dolt add .
dolt commit -am "init"
}
@@ -363,6 +364,7 @@ INSERT INTO dupe (c0,c1) VALUES
(1,1),(1,1),(1,1),(1,1),(1,1),
(1,1),(1,1),(1,1),(1,1),(1,1);
SQL
dolt add .
dolt commit -am "created table dupe"
}