Fixed test and deleted redundant tests

This commit is contained in:
Zach Musgrave
2023-01-18 19:58:31 -08:00
parent 1c6924dbc0
commit a7fead9d76

View File

@@ -18,23 +18,6 @@ teardown() {
teardown_common
}
@test "sql-branch: DOLT_BRANCH works" {
run dolt branch
[[ ! "$output" =~ "new_branch" ]] || false
run dolt sql -q "call dolt_branch('new-branch')"
[ $status -eq 0 ]
# should create new branch and should not checkout the new branch
run dolt status
[ $status -eq 0 ]
[[ "$output" =~ "main" ]] || false
run dolt branch
[ $status -eq 0 ]
[[ "$output" =~ "new-branch" ]] || false
}
@test "sql-branch: CALL DOLT_BRANCH works" {
run dolt branch
[[ ! "$output" =~ "new_branch" ]] || false
@@ -69,20 +52,7 @@ teardown() {
[[ "$output" =~ "new-branch" ]] || false
}
@test "sql-branch: DOLT_BRANCH throws error" {
# branches that already exist
dolt branch existing_branch
run dolt sql -q "call dolt_branch('existing_branch')"
[ $status -eq 1 ]
[[ "$output" =~ "fatal: A branch named 'existing_branch' already exists." ]] || false
# empty branch
run dolt sql -q "call dolt_branch('')"
[ $status -eq 1 ]
[[ "$output" =~ "error: cannot branch empty string" ]] || false
}
@test "sql-branch: CALL DOLT_BRANCH throws error" {
@test "sql-branch: CALL DOLT_BRANCH error cases" {
# branches that already exist
dolt branch existing_branch
run dolt sql -q "CALL DOLT_BRANCH('existing_branch')"
@@ -95,37 +65,6 @@ teardown() {
[[ "$output" =~ "error: cannot branch empty string" ]]
}
@test "sql-branch: DOLT_BRANCH -c copies not current branch and stays on current branch" {
dolt add . && dolt commit -m "0, 1, and 2 in test table"
run dolt status
[[ "$output" =~ "main" ]] || false
dolt checkout -b original
dolt sql -q "insert into test values (4);"
dolt add .
dolt commit -m "add 4 in original"
dolt checkout main
# Current branch should be still main with test table without entry 4
run dolt sql << SQL
call dolt_branch('-c', 'original', 'copy');
SELECT * FROM test WHERE pk > 3;
SQL
[ $status -eq 0 ]
[[ ! "$output" =~ "4" ]] || false
run dolt status
[ $status -eq 0 ]
[[ "$output" =~ "main" ]] || false
run dolt checkout copy
[ $status -eq 0 ]
run dolt sql -q "SELECT * FROM test WHERE pk > 3;"
[[ "$output" =~ "4" ]] || false
}
@test "sql-branch: CALL DOLT_BRANCH -c copies not current branch and stays on current branch" {
dolt add . && dolt commit -m "0, 1, and 2 in test table"
run dolt status
@@ -157,37 +96,6 @@ SQL
[[ "$output" =~ "4" ]] || false
}
@test "sql-branch: DOLT_BRANCH -c throws error on error cases" {
run dolt status
[[ "$output" =~ "main" ]] || false
# branch copying from is empty
run dolt sql -q "call dolt_branch('-c','','copy')"
[ $status -eq 1 ]
[[ "$output" =~ "error: cannot branch empty string" ]] || false
# branch copying to is empty
run dolt sql -q "call dolt_branch('-c','main','')"
[ $status -eq 1 ]
[[ "$output" =~ "error: cannot branch empty string" ]] || false
dolt branch 'existing_branch'
run dolt branch
[[ "$output" =~ "main" ]] || false
[[ "$output" =~ "existing_branch" ]] || false
[[ ! "$output" =~ "original" ]] || false
# branch copying from that don't exist
run dolt sql -q "call dolt_branch('-c', 'original', 'copy');"
[ $status -eq 1 ]
[[ "$output" =~ "fatal: A branch named 'original' not found" ]] || false
# branch copying to that exists
run dolt sql -q "call dolt_branch('-c', 'main', 'existing_branch');"
[ $status -eq 1 ]
[[ "$output" =~ "fatal: A branch named 'existing_branch' already exists." ]] || false
}
@test "sql-branch: CALL DOLT_BRANCH -c throws error on error cases" {
run dolt status
[[ "$output" =~ "main" ]] || false
@@ -219,19 +127,6 @@ SQL
[[ "$output" =~ "fatal: A branch named 'existing_branch' already exists." ]]
}
@test "sql-branch: DOLT_BRANCH works as insert into dolt_branches table" {
dolt add . && dolt commit -m "1, 2, and 3 in test table"
run dolt sql -q "SELECT hash FROM dolt_branches WHERE name='main';"
[ $status -eq 0 ]
mainhash=$output
dolt sql -q "call dolt_branch('feature-branch');"
run dolt sql -q "SELECT hash FROM dolt_branches WHERE name='feature-branch';"
[ $status -eq 0 ]
[ "$output" = "$mainhash" ]
}
@test "sql-branch: CALL DOLT_BRANCH works as insert into dolt_branches table" {
dolt add . && dolt commit -m "1, 2, and 3 in test table"
@@ -245,29 +140,6 @@ SQL
[ "$output" = "$mainhash" ]
}
@test "sql-branch: call dolt_branch to rename and delete" {
dolt add . && dolt commit -m "1, 2, and 3 in test table"
dolt branch new_branch
run dolt sql -q "call dolt_branch('-m', 'new_branch', 'changed');"
[ $status -eq 0 ]
run dolt sql -q "call dolt_branch('-d', 'changed');"
[ $status -eq 0 ]
dolt branch branch_with_unpushed_commit
dolt checkout branch_with_unpushed_commit
dolt commit --allow-empty -am 'empty commit'
dolt checkout main
run dolt sql -q "call dolt_branch('-d', 'branch_with_unpushed_commit');"
[ $status -eq 1 ]
[[ "$output" =~ "attempted to delete a branch that is not fully merged" ]] || false
run dolt sql -q "call dolt_branch('-D', 'branch_with_unpushed_commit');"
[ $status -eq 0 ]
}
@test "sql-branch: CALL DOLT_BRANCH to rename and delete" {
dolt add . && dolt commit -m "1, 2, and 3 in test table"
dolt branch new_branch
@@ -285,7 +157,7 @@ SQL
run dolt sql -q "CALL DOLT_BRANCH('-d', 'branch_with_unpushed_commit');"
[ $status -eq 1 ]
[[ "$output" =~ "attempted to delete a branch that is not fully merged" ]] || false
[[ "$output" =~ "not fully merged" ]] || false
run dolt sql -q "CALL DOLT_BRANCH('-D', 'branch_with_unpushed_commit');"
[ $status -eq 0 ]