mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-19 10:23:36 -06:00
second pass on tests
This commit is contained in:
25
integration-tests/bats/add-patch-expect/no_then_a.expect
Executable file
25
integration-tests/bats/add-patch-expect/no_then_a.expect
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
set env(NO_COLOR) 1
|
||||
|
||||
source "$env(BATS_CWD)/helper/common_expect_functions.tcl"
|
||||
|
||||
spawn dolt add -p
|
||||
|
||||
# This test will reject the first change for each of the 3 tables, then accept the rest.
|
||||
|
||||
expect_with_defaults_2 {| \+ | 0 | Yellow | 255 | 255 | 0 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "n\r"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | Green | 0 | 255 | 0 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "ar"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | 3.3 | 4.4 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "n\r"; }
|
||||
|
||||
expect_with_defaults_2 {| < | 3 | 5.5 | 6.6 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "a\r"; }
|
||||
|
||||
expect_with_defaults_2 {| < | 1 | neil |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "n\r"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | sami |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "a\r"; }
|
||||
|
||||
expect eof
|
||||
exit
|
||||
26
integration-tests/bats/add-patch-expect/yes_then_d.expect
Executable file
26
integration-tests/bats/add-patch-expect/yes_then_d.expect
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
set env(NO_COLOR) 1
|
||||
|
||||
source "$env(BATS_CWD)/helper/common_expect_functions.tcl"
|
||||
|
||||
# Verify add -p . gets all the tables.
|
||||
spawn dolt add -p .
|
||||
|
||||
# This test will accept the first change for each of the 3 tables, then skip the rest.
|
||||
|
||||
expect_with_defaults_2 {| \+ | 0 | Yellow | 255 | 255 | 0 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "y\r"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | Green | 0 | 255 | 0 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "d\r"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | 3.3 | 4.4 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "y\r"; }
|
||||
|
||||
expect_with_defaults_2 {| < | 3 | 5.5 | 6.6 |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "d\r"; }
|
||||
|
||||
expect_with_defaults_2 {| < | 1 | neil |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "y\r"; }
|
||||
|
||||
expect_with_defaults_2 {| - | 2 | sami |} {Stage this row \[y,n,q,a,d,s,\?\]\? } { send "d\r"; }
|
||||
|
||||
expect eof
|
||||
exit
|
||||
@@ -27,7 +27,7 @@ UPDATE colors SET name = 'SkyBlue', red = 0, green = 128, blue = 255 WHERE pk =
|
||||
UPDATE coordinates SET y = 100.001 WHERE pk = 3;
|
||||
|
||||
INSERT INTO names VALUES (4,'john');
|
||||
INSERT INTO colors VALUES (0, 'Yellow', 255, 255, 0);
|
||||
INSERT INTO colors VALUES (0, 'Yellow', 255, 255, 0); // use 0 pk to ensure ordering is different from other tables.
|
||||
INSERT INTO coordinates VALUES (4, 42.24, 23.32);
|
||||
|
||||
DELETE FROM names WHERE pk = 2;
|
||||
@@ -148,6 +148,7 @@ teardown() {
|
||||
[[ ! "$output" =~ "john" ]] || false # Value for inserted row - should not be there.
|
||||
}
|
||||
|
||||
# bats test_tags=no_lambda
|
||||
@test "add-patch: y/n repeatedly with restarts" {
|
||||
# This test repeatedly does 'y/n/y/s' until the program exits.
|
||||
run $BATS_TEST_DIRNAME/add-patch-expect/restart_multiple_times.expect
|
||||
@@ -173,7 +174,77 @@ teardown() {
|
||||
[[ ! "$output" =~ "john" ]] || false # last promoted row - should not be staged.
|
||||
}
|
||||
|
||||
# bats test_tags=no_lambda
|
||||
@test "add-patch: y then d" {
|
||||
# Accept the first change for each table, then skip the rest.
|
||||
run $BATS_TEST_DIRNAME/add-patch-expect/yes_then_d.expect
|
||||
[ $status -eq 0 ]
|
||||
|
||||
run dolt sql -q "select name from colors AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "Yellow" ]] || false
|
||||
[[ "$output" =~ "Red" ]] || false
|
||||
[[ "$output" =~ "Green" ]] || false
|
||||
[[ "$output" =~ "Blue" ]] || false
|
||||
# verify no extra rows in table we didn't look for.
|
||||
run dolt sql -q "select sum(pk) as s from colors AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 6 |" ]] || false # Yellow added as pk=0, so 0+1+2+3
|
||||
|
||||
run dolt sql -q "select pk, y from coordinates AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 1 | 2.2 |" ]] || false
|
||||
[[ "$output" =~ "| 3 | 6.6 |" ]] || false
|
||||
# verify no extra rows in table we didn't look for.
|
||||
run dolt sql -q "select sum(pk) as s from coordinates AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 4 |" ]] || false
|
||||
|
||||
run dolt sql -q "select pk, name from names AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 1 | joey |" ]] || false
|
||||
[[ "$output" =~ "| 2 | sami |" ]] || false
|
||||
[[ "$output" =~ "| 3 | jane |" ]] || false
|
||||
run dolt sql -q "select sum(pk) as s from names AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 6 |" ]] || false
|
||||
}
|
||||
|
||||
# bats test_tags=no_lambda
|
||||
@test "add-patch: n then a" {
|
||||
# Accept the reject fir change, then accept the rest.
|
||||
run $BATS_TEST_DIRNAME/add-patch-expect/no_then_a.expect
|
||||
[ $status -eq 0 ]
|
||||
|
||||
run dolt sql -q "select pk,name from colors AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 1 | Red |" ]] || false
|
||||
[[ "$output" =~ "| 3 | SkyBlue |" ]] || false
|
||||
# verify no extra rows in table we didn't look for.
|
||||
run dolt sql -q "select sum(pk) as s from colors AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 4 |" ]] || false
|
||||
|
||||
run dolt sql -q "select pk, y from coordinates AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 1 | 2.2 |" ]] || false
|
||||
[[ "$output" =~ "| 2 | 4.4 |" ]] || false
|
||||
[[ "$output" =~ "| 3 | 100.001 |" ]] || false
|
||||
[[ "$output" =~ "| 4 | 23.32 |" ]] || false
|
||||
# verify no extra rows in table we didn't look for.
|
||||
run dolt sql -q "select sum(pk) as s from coordinates AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 10 |" ]] || false
|
||||
|
||||
run dolt sql -q "select pk, name from names AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 1 | neil |" ]] || false
|
||||
[[ "$output" =~ "| 2 | sami |" ]] || false
|
||||
[[ "$output" =~ "| 3 | jane |" ]] || false
|
||||
run dolt sql -q "select sum(pk) as s from names AS OF STAGED"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "| 6 |" ]] || false
|
||||
}
|
||||
|
||||
# Test needed:
|
||||
# restart workflow.
|
||||
# add keyless table tests.
|
||||
|
||||
Reference in New Issue
Block a user