Removed server_query in all bats except sql-server.bats

This commit is contained in:
Tim Sehn
2022-10-28 11:53:55 -07:00
parent c900de6969
commit cfd7ff015a
3 changed files with 38 additions and 21 deletions
+11 -11
View File
@@ -80,15 +80,14 @@ make_it() {
start_sql_server "dolt_repo_$$"
# Can't string together multiple queries in dolt sql-client
server_query "dolt_repo_$$" 1 dolt "" 'call dolt_checkout("to_keep"); call dolt_branch("-D", "main");' ""
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q 'call dolt_checkout("to_keep"); call dolt_branch("-D", "main");'
# Against the default branch it fails
run dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "SELECT * FROM test"
[ $status -ne 0 ]
# Against to_keep it succeeds
server_query "dolt_repo_$$/to_keep" 1 dolt "" "SELECT * FROM test" "id\n" ""
dolt sql-client --use-db "dolt_repo_$$/to_keep" -u dolt -P $PORT -q "SELECT * FROM test"
}
@test "deleted-branches: can SQL connect with existing branch revision specifier when dolt_default_branch is invalid" {
@@ -103,7 +102,7 @@ make_it() {
[ $status -ne 0 ]
# Against main, which exists it succeeds
server_query "dolt_repo_$$/main" 1 dolt "" "SELECT * FROM test" "id\n" ""
dolt sql-client --use-db "dolt_repo_$$/main" -u dolt -P $PORT -q "SELECT * FROM test"
}
@test "deleted-branches: calling DOLT_CHECKOUT on SQL connection with existing branch revision specifier when dolt_default_branch is invalid does not panic" {
@@ -114,10 +113,11 @@ make_it() {
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "SET @@GLOBAL.dolt_repo_$$_default_branch = 'this_branch_does_not_exist'" ""
# We are able to use a database branch revision in the connection string
server_query "dolt_repo_$$/main" 1 dolt "" "SELECT * FROM test;"
dolt sql-client --use-db "dolt_repo_$$/main" -u dolt -P $PORT -q "SELECT * FROM test;"
# Trying to checkout a new branch throws an error, but doesn't panic
run server_query "dolt_repo_$$/main" 1 dolt "" "CALL DOLT_CHECKOUT('to_keep');" "" 1
run dolt sql-client --use-db "dolt_repo_$$/main" -u dolt -P $PORT -q"CALL DOLT_CHECKOUT('to_keep');"
[ $status -ne 0 ]
[[ "$output" =~ "branch not found" ]] || false
}
@@ -128,14 +128,14 @@ make_it() {
start_sql_server "dolt_repo_$$"
server_query "dolt_repo_$$" 1 dolt "" 'call dolt_checkout("to_keep"); call dolt_branch("-D", "main");' ""
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "call dolt_checkout('to_keep'); call dolt_branch('-D', 'main');"
# We are able to use a database branch revision in the connection string
server_query "dolt_repo_$$/to_keep" 1 dolt "" "SELECT * FROM test;"
dolt sql-client --use-db "dolt_repo_$$/to_keep" -u dolt -P $PORT -q "SELECT * FROM test;"
# Trying to checkout a new branch throws an error, but doesn't panic
run server_query "dolt_repo_$$/to_keep" 1 dolt "" "CALL DOLT_CHECKOUT('to_checkout');" "" 1
run dolt sql-client --use-db "dolt_repo_$$/to_keep" -u dolt -P $PORT -q "CALL DOLT_CHECKOUT('to_checkout');"
[ $status -ne 0 ]
[[ "$output" =~ "branch not found" ]] || false
}
@@ -148,7 +148,7 @@ make_it() {
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "SET @@GLOBAL.dolt_repo_$$_default_branch = 'to_keep'" ""
server_query "dolt_repo_$$" 1 dolt "" 'call dolt_checkout("to_keep"); call dolt_branch("-D", "main");' ""
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "call dolt_checkout('to_keep'); call dolt_branch('-D', 'main');"
dolt sql-client --use-db "dolt_repo_$$" -u dolt -P $PORT -q "SELECT * FROM test"
+7 -1
View File
@@ -30,7 +30,13 @@ teardown() {
@test "multidb: database default branches" {
cd dbs1
start_multi_db_server repo1
server_query repo1 1 dolt "" "create database new; use new; call dcheckout('-b', 'feat'); create table t (x int); call dolt_add('.'); call dcommit('-am', 'cm'); set @@global.new_default_branch='feat'"
dolt sql-client -u dolt -P $PORT --use-db repo1 -q "create database new;
use new;
call dcheckout('-b', 'feat');
create table t (x int);
call dolt_add('.');
call dcommit('-am', 'cm');
set @@global.new_default_branch='feat'"
dolt sql-client -u dolt --use-db '' -P $PORT -q "use repo1"
}
+20 -9
View File
@@ -218,22 +218,30 @@ teardown() {
# Can't use dolt sql-client to connect to branches
# Connecting to heads that exist only on the remote should work fine (they get fetched)
server_query "repo2/new_feature" 1 dolt "" "show tables" "Tables_in_repo2/new_feature\ntest"
server_query repo2 1 dolt "" 'use `repo2/new_feature2`' ""
server_query repo2 1 dolt "" 'select * from `repo2/new_feature2`.test' "pk\n0\n1\n2"
dolt sql-client --use-db "repo2/new_feature" -u dolt -P $PORT -q "show tables" "Tables_in_repo2/new_feature\ntest"
dolt sql-client --use-db repo2 -P $PORT -u dolt -q 'use `repo2/new_feature2`'
run dolt sql-client --use-db repo2 -P $PORT -u dolt -q 'select * from `repo2/new_feature2`.test'
[ $status -eq 0 ]
[[ "$output" =~ "pk" ]] || false
[[ "$output" =~ " 0 " ]] || false
[[ "$output" =~ " 1 " ]] || false
[[ "$output" =~ " 2 " ]] || false
# Connecting to heads that don't exist should error out
run server_query "repo2/notexist" 1 dolt "" 'use `repo2/new_feature2`' "" 1
run dolt sql-client --use-db "repo2/notexist" -u dolt -P $PORT -q 'use `repo2/new_feature2`'
[ $status -ne 0 ]
[[ $output =~ "database not found" ]] || false
run server_query repo2 1 dolt "" 'use `repo2/notexist`' "" 1
run dolt sql-client --use-db repo2 -P $PORT -u dolt -q 'use `repo2/notexist`'
[ $status -ne 0 ]
[[ $output =~ "database not found" ]] || false
# Creating a branch locally that doesn't exist on the remote
# works, but connecting to it is an error (nothing to pull)
server_query "repo2/new_feature" 1 dolt "" "select dolt_checkout('-b', 'new_branch') as b" "b\n0"
dolt sql-client --use-db "repo2/new_feature" -u dolt -P $PORT -q "select dolt_checkout('-b', 'new_branch')"
run server_query "repo2/new_branch" 1 dolt "" "show tables" "Table\ntest" "" 1
run dolt sql-client --use-db "repo2/new_branch" -u dolt -P $PORT -q "show tables"
[ $status -ne 0 ]
[[ $output =~ "database not found" ]] || false
}
@@ -319,7 +327,10 @@ teardown() {
[ "$output" = "" ]
# Can't connect to a specific branch with dolt sql-client
server_query "repo2/feature-branch" 1 dolt "" "SHOW Tables" "Tables_in_repo2/feature-branch\ntest"
run dolt sql-client --use-db "repo2/feature-branch" -u dolt -P $PORT -q "SHOW Tables"
[ $status -eq 0 ]
[[ $output =~ "feature-branch" ]] || false
[[ $output =~ "test" ]] || false
}
@test "remotes-sql-server: connect to hash works" {
@@ -340,7 +351,7 @@ teardown() {
[[ $output =~ "Tables_in_repo2" ]] || false
[[ $output =~ "test" ]] || false
run dolt sql-client --use-db repo2 -P $PORT -u dolt -q"use \`repo2/$head_hash\`"
run dolt sql-client --use-db repo2 -P $PORT -u dolt -q "use \`repo2/$head_hash\`"
[ $status -eq 0 ]
[ "$output" = "" ]
}