Merge pull request #4661 from dolthub/tim/sql-client-bats

Bats tests for sql-client fixes
This commit is contained in:
Tim Sehn
2022-10-28 13:50:15 -07:00
committed by GitHub

View File

@@ -72,4 +72,65 @@ teardown() {
run dolt sql-client
[ "$status" -eq 1 ]
[[ "$output" =~ "--user or -u argument is required" ]] || false
}
}
@test "sql-client: multiple statments in --query" {
cd repo1
start_sql_server repo1
dolt sql-client -u dolt -P $PORT --use-db repo1 -q "
create table t(c int);
insert into t values (0),(1);
update t set c=2 where c=0;"
run dolt sql-client -u dolt -P $PORT --use-db repo1 -q "select c from t"
[ $status -eq 0 ]
[[ $output =~ " 1 " ]] || false
[[ $output =~ " 2 " ]] || false
! [[ $output =~ " 0 " ]] || false
}
@test "sql-client: no-auto-commit" {
cd repo1
start_sql_server repo1
dolt sql-client -u dolt -P $PORT --use-db repo1 --no-auto-commit -q "CREATE TABLE one_pk (
pk BIGINT NOT NULL,
c1 BIGINT,
c2 BIGINT,
PRIMARY KEY (pk)
)"
run dolt ls
[ "$status" -eq 0 ]
[[ "$output" =~ "No tables in working set" ]] || false
# Now issue a manual commit
dolt sql-client -u dolt -P $PORT --use-db repo1 --no-auto-commit -q "CREATE TABLE one_pk (
pk BIGINT NOT NULL,
c1 BIGINT,
c2 BIGINT,
PRIMARY KEY (pk));
COMMIT;"
run dolt ls
[ "$status" -eq 0 ]
[[ "$output" =~ "one_pk" ]] || false
}
@test "sql-client: connect directly to a branch using --use-db" {
cd repo1
dolt branch branch1
start_sql_server repo1
dolt sql-client -u dolt -P $PORT --use-db repo1/branch1 -q "
create table t(c int);
insert into t values (0),(1);
update t set c=2 where c=0;"
run dolt sql-client -u dolt -P $PORT --use-db repo1/branch1 -q "select c from t"
[ $status -eq 0 ]
[[ $output =~ " 1 " ]] || false
[[ $output =~ " 2 " ]] || false
! [[ $output =~ " 0 " ]] || false
run dolt sql-client -u dolt -P $PORT --use-db repo1 -q "select c from t"
[ $status -ne 0 ]
[[ $output =~ "not found" ]] || false
}