Skip to content

Commit

Permalink
fix batsg
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp committed Nov 14, 2023
1 parent 572089b commit 90f31d3
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 254 deletions.
2 changes: 1 addition & 1 deletion integration-tests/bats/blame.bats
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ SQL
@test "blame: returns an error when the table is not found in the given revision" {
run dolt blame HEAD~4 blame_test
[ "$status" -eq 1 ]
[[ "$output" =~ "View 'dolt_repo_$$.dolt_blame_blame_test' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" ]] || false
[[ "$output" =~ "View 'dolt-repo-$$.dolt_blame_blame_test' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" ]] || false
}

@test "blame: pk ordered output" {
Expand Down
40 changes: 20 additions & 20 deletions integration-tests/bats/branch-control.bats
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ setup_test_user() {
@test "branch-control: test basic branch write permissions" {
setup_test_user

dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'test-branch', 'test', '%', 'write')"
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'test-branch', 'test', '%', 'write')"
dolt branch test-branch

start_sql_server
Expand Down Expand Up @@ -120,7 +120,7 @@ setup_test_user() {
dolt sql -q "create user test2"
dolt sql -q "grant all on *.* to test2"

dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'test-branch', 'test', '%', 'admin')"
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'test-branch', 'test', '%', 'admin')"
dolt branch test-branch

start_sql_server
Expand All @@ -134,21 +134,21 @@ setup_test_user() {
dolt -u test sql -q "call dolt_checkout('test-branch'); create table t (c1 int)"

# Admin can make other users
dolt -u test sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'test-branch', 'test2', '%', 'write')"
dolt -u test sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'test-branch', 'test2', '%', 'write')"
run dolt -u test sql --result-format csv -q "select * from dolt_branch_control"
[ $status -eq 0 ]
[ ${lines[0]} = "database,branch,user,host,permissions" ]
[ ${lines[1]} = "dolt_repo_$$,test-branch,test,%,admin" ]
[ ${lines[2]} = "dolt_repo_$$,test-branch,root,localhost,admin" ]
[ ${lines[3]} = "dolt_repo_$$,test-branch,test2,%,write" ]
[ ${lines[1]} = "dolt-repo-$$,test-branch,test,%,admin" ]
[ ${lines[2]} = "dolt-repo-$$,test-branch,root,localhost,admin" ]
[ ${lines[3]} = "dolt-repo-$$,test-branch,test2,%,write" ]

# test2 can see all branch permissions
run dolt -u test2 sql --result-format csv -q "select * from dolt_branch_control"
[ $status -eq 0 ]
[ ${lines[0]} = "database,branch,user,host,permissions" ]
[ ${lines[1]} = "dolt_repo_$$,test-branch,test,%,admin" ]
[ ${lines[2]} = "dolt_repo_$$,test-branch,root,localhost,admin" ]
[ ${lines[3]} = "dolt_repo_$$,test-branch,test2,%,write" ]
[ ${lines[1]} = "dolt-repo-$$,test-branch,test,%,admin" ]
[ ${lines[2]} = "dolt-repo-$$,test-branch,root,localhost,admin" ]
[ ${lines[3]} = "dolt-repo-$$,test-branch,test2,%,write" ]

# test2 now has write permissions on test-branch
dolt -u test2 sql -q "call dolt_checkout('test-branch'); insert into t values(0)"
Expand All @@ -159,7 +159,7 @@ setup_test_user() {
run dolt -u test sql --result-format csv -q "select * from dolt_branch_control"
[ $status -eq 0 ]
[ ${lines[0]} = "database,branch,user,host,permissions" ]
[ ${lines[1]} = "dolt_repo_$$,test-branch,test,%,admin" ]
[ ${lines[1]} = "dolt-repo-$$,test-branch,test,%,admin" ]

# test2 cannot write to branch
run dolt -u test2 sql -q "call dolt_checkout('test-branch'); insert into t values(1)"
Expand All @@ -170,7 +170,7 @@ setup_test_user() {
@test "branch-control: creating a branch grants admin permissions" {
setup_test_user

dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'main', 'test', '%', 'write')"
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'main', 'test', '%', 'write')"

start_sql_server

Expand All @@ -179,8 +179,8 @@ setup_test_user() {
run dolt -u test sql --result-format csv -q "select * from dolt_branch_control"
[ $status -eq 0 ]
[ ${lines[0]} = "database,branch,user,host,permissions" ]
[ ${lines[1]} = "dolt_repo_$$,main,test,%,write" ]
[ ${lines[2]} = "dolt_repo_$$,test-branch,test,%,admin" ]
[ ${lines[1]} = "dolt-repo-$$,main,test,%,write" ]
[ ${lines[2]} = "dolt-repo-$$,test-branch,test,%,admin" ]
}

@test "branch-control: test branch namespace control" {
Expand All @@ -189,16 +189,16 @@ setup_test_user() {
dolt sql -q "create user test2"
dolt sql -q "grant all on *.* to test2"

dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'test-
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'test-
branch', 'test', '%', 'admin')"
dolt sql -q "insert into dolt_branch_namespace_control values ('dolt_repo_$$', 'test-%', 'test2', '%')"
dolt sql -q "insert into dolt_branch_namespace_control values ('dolt-repo-$$', 'test-%', 'test2', '%')"

start_sql_server

run dolt -u test sql --result-format csv -q "select * from dolt_branch_namespace_control"
[ $status -eq 0 ]
[ ${lines[0]} = "database,branch,user,host" ]
[ ${lines[1]} = "dolt_repo_$$,test-%,test2,%" ]
[ ${lines[1]} = "dolt-repo-$$,test-%,test2,%" ]

# test cannot create test-branch
run dolt -u test sql -q "call dolt_branch('test-branch')"
Expand All @@ -215,8 +215,8 @@ branch', 'test', '%', 'admin')"
dolt sql -q "create user test2"
dolt sql -q "grant all on *.* to test2"

dolt sql -q "insert into dolt_branch_namespace_control values ('dolt_repo_$$', 'test/%', 'test', '%')"
dolt sql -q "insert into dolt_branch_namespace_control values ('dolt_repo_$$', 'test2/%', 'test2', '%')"
dolt sql -q "insert into dolt_branch_namespace_control values ('dolt-repo-$$', 'test/%', 'test', '%')"
dolt sql -q "insert into dolt_branch_namespace_control values ('dolt-repo-$$', 'test2/%', 'test2', '%')"

start_sql_server

Expand All @@ -238,8 +238,8 @@ branch', 'test', '%', 'admin')"
dolt sql -q "grant all on *.* to admin"
dolt sql -q "insert into dolt_branch_control values ('%', '%', 'admin', '%', 'admin')"

dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', 'test-branch', 'test', '%', 'read')"
dolt sql -q "insert into dolt_branch_control values ('dolt_repo_$$', '%', 'test', '%', 'write')"
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', 'test-branch', 'test', '%', 'read')"
dolt sql -q "insert into dolt_branch_control values ('dolt-repo-$$', '%', 'test', '%', 'write')"
dolt branch test-branch

start_sql_server
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/bats/create-views.bats
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ SQL
# check information_schema.VIEWS table
# TODO: view_definition should be "select `mybin`.`my_users`.`id` AS `id` from `mybin`.`my_users` order by `mybin`.`my_users`.`id`"
run dolt sql -q "select * from information_schema.VIEWS;" -r csv
[[ "$output" =~ "def,dolt_repo_$$,my_users_view,select id from my_users order by id asc,NONE,YES,root@localhost,DEFINER,utf8mb4,utf8mb4_0900_bin" ]] || false
[[ "$output" =~ "def,dolt-repo-$$,my_users_view,select id from my_users order by id asc,NONE,YES,root@localhost,DEFINER,utf8mb4,utf8mb4_0900_bin" ]] || false
}

@test "create-views: view referencing table selects values inserted after it was created" {
Expand Down Expand Up @@ -292,7 +292,7 @@ SQL
[ "$status" -eq 0 ]
run dolt sql -q 'select * from all_users'
[ "$status" -eq 1 ]
[[ "${lines[0]}" =~ "View 'dolt_repo_$$.all_users' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" ]] || false
[[ "${lines[0]}" =~ "View 'dolt-repo-$$.all_users' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" ]] || false
run dolt sql -q 'drop view all_users'
[ "$status" -eq 0 ]
}
Expand Down Expand Up @@ -354,7 +354,7 @@ SQL
[[ "$output" =~ "select * from t1" ]] || false

# should use the view definition from branch named, data from branch named
run dolt sql -r csv -q "select * from \`dolt_repo_$$/view\`.v1 order by 1"
run dolt sql -r csv -q "select * from \`dolt-repo-$$/view\`.v1 order by 1"
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "${lines[1]}" =~ "1,1" ]] || false
Expand Down
1 change: 1 addition & 0 deletions integration-tests/bats/db-revision-specifiers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load $BATS_TEST_DIRNAME/helper/common.bash

setup() {
setup_common
dolt config --add database.disablehyphen true
database_name=dolt_repo_$$

dolt sql -q "CREATE TABLE test(pk int PRIMARY KEY, color varchar(200))"
Expand Down
1 change: 1 addition & 0 deletions integration-tests/bats/deleted-branches.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
skiponwindows "Missing dependencies"

setup_common
dolt config --add database.disablehyphen true
}

teardown() {
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/bats/dump.bats
Original file line number Diff line number Diff line change
Expand Up @@ -889,12 +889,12 @@ SQL
dolt sql < ../doltdump.sql
[ $status -eq 0 ]

run dolt sql -q "USE dolt_repo_$$; SHOW TABLES;"
run dolt sql -q "USE \`dolt-repo-$$\`; SHOW TABLES;"
[ $status -eq 0 ]
[[ $output =~ "table1" ]] || false
[[ $output =~ "view1" ]] || false

run dolt sql -r csv -q "USE dolt_repo_$$; CALL procedure1;"
run dolt sql -r csv -q "USE \`dolt-repo-$$\`; CALL procedure1;"
[ $status -eq 0 ]
[[ $output =~ "pk,col1" ]] || false
[[ $output =~ "2,1" ]] || false
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/bats/foreign-keys.bats
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ SQL

# check information_schema.TABLE_CONSTRAINTS table
run dolt sql -q "select * from information_schema.TABLE_CONSTRAINTS where table_name = 'materials';" -r csv
[[ "$output" =~ "def,dolt_repo_$$,PRIMARY,dolt_repo_$$,materials,PRIMARY KEY,YES" ]] || false
[[ "$output" =~ "def,dolt_repo_$$,jb6i5huc,dolt_repo_$$,materials,FOREIGN KEY,YES" ]] || false
[[ "$output" =~ "def,dolt-repo-$$,PRIMARY,dolt-repo-$$,materials,PRIMARY KEY,YES" ]] || false
[[ "$output" =~ "def,dolt-repo-$$,jb6i5huc,dolt-repo-$$,materials,FOREIGN KEY,YES" ]] || false

# check information_schema.TABLE_CONSTRAINTS_EXTENSIONS table
run dolt sql -q "select constraint_name from information_schema.TABLE_CONSTRAINTS_EXTENSIONS where table_name = 'materials';" -r csv
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/bats/remotes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ SQL
# Test cloning from a server remote
run dolt sql -q "call dolt_clone('http://localhost:50051/test-org/test-repo');"
[ "$status" -eq 0 ]
run dolt sql -q "use test_repo; show tables;"
run dolt sql -q "use \`test-repo\`; show tables;"
[ "$status" -eq 0 ]
[[ "$output" =~ "test_table" ]] || false
}
Expand Down
6 changes: 2 additions & 4 deletions integration-tests/bats/sql-checkout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ SQL
}

@test "sql-checkout: DOLT_CHECKOUT updates the head ref session var" {
dolt config --add database.disablehyphen true
run dolt sql <<SQL
call dolt_checkout('-b', 'feature-branch');
select @@dolt_repo_$$_head_ref;
Expand All @@ -140,6 +141,7 @@ SQL
}

@test "sql-checkout: CALL DOLT_CHECKOUT updates the head ref session var" {
dolt config --add database.disablehyphen true
run dolt sql <<SQL
CALL DOLT_CHECKOUT('-b', 'feature-branch');
select @@dolt_repo_$$_head_ref;
Expand Down Expand Up @@ -599,7 +601,3 @@ SQL
get_head_commit() {
dolt log -n 1 | grep -m 1 commit | awk '{print $2}'
}

get_working_hash() {
dolt sql -q "select @@dolt_repo_$$_working" | sed -n 4p | sed -e 's/|//' -e 's/|//' -e 's/ //'
}
4 changes: 4 additions & 0 deletions integration-tests/bats/sql-commit.bats
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ SQL
}

@test "sql-commit: DOLT_COMMIT updates session variables" {
dolt config --add database.disablehyphen true
head_variable=@@dolt_repo_$$_head
head_commit=$(get_head_commit)
run dolt sql << SQL
Expand All @@ -232,6 +233,7 @@ SQL
}

@test "sql-commit: CALL DOLT_COMMIT updates session variables" {
dolt config --add database.disablehyphen true
head_variable=@@dolt_repo_$$_head
head_commit=$(get_head_commit)
run dolt sql << SQL
Expand All @@ -252,6 +254,7 @@ SQL
}

@test "sql-commit: DOLT_COMMIT with unstaged tables leaves them in the working set" {
dolt config --add database.disablehyphen true
head_variable=@@dolt_repo_$$_head

run dolt sql << SQL
Expand Down Expand Up @@ -311,6 +314,7 @@ SQL
}

@test "sql-commit: CALL DOLT_COMMIT with unstaged tables leaves them in the working set" {
dolt config --add database.disablehyphen true
head_variable=@@dolt_repo_$$_head

run dolt sql << SQL
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/bats/sql-create-database.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SQL

run dolt sql -q "SHOW DATABASES;"
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "mydb" ]] || false

Expand All @@ -43,7 +43,7 @@ SQL

run dolt sql -q "SHOW DATABASES;"
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "mydb" ]] || false

Expand All @@ -65,7 +65,7 @@ SQL

run dolt sql -q "SHOW DATABASES;"
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "mydb" ]] || false

Expand Down Expand Up @@ -142,7 +142,7 @@ SQL
[ "$status" -eq 0 ]
[[ "$output" =~ "mydb2" ]] || false
[[ ! "$output" =~ "mydb1" ]] || false
[[ ! "$output" =~ "dolt_repo_$$" ]] || false
[[ ! "$output" =~ "dolt-repo-$$" ]] || false

# data-dir with abs path
absdir="/tmp/$$/db_dir"
Expand Down Expand Up @@ -221,7 +221,7 @@ SQL
dolt sql -q "CREATE DATABASE IF NOT EXISTS test;"
run dolt sql -q "SHOW DATABASES;"
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "test" ]] || false

Expand Down Expand Up @@ -278,7 +278,7 @@ SQL
dolt sql -q "CREATE SCHEMA mydb"

run dolt sql -q "SHOW DATABASES;"
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "mydb" ]] || false
}
Expand Down Expand Up @@ -311,7 +311,7 @@ SQL

run dolt sql -q "SHOW DATABASES;"
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "dolt-repo-$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "metabase" ]] || false

Expand Down
2 changes: 2 additions & 0 deletions integration-tests/bats/sql-merge.bats
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ SQL
}

@test "sql-merge: DOLT_MERGE correctly returns head and working session variables." {
dolt config --add database.disablehyphen true
dolt sql << SQL
call dolt_commit('-a', '-m', 'Step 1');
call dolt_checkout('-b', 'feature-branch');
Expand Down Expand Up @@ -316,6 +317,7 @@ SQL
}

@test "sql-merge: DOLT_MERGE -no-ff correctly changes head and working session variables." {
dolt config --add database.disablehyphen true
dolt sql << SQL
call dolt_commit('-a', '-m', 'Step 1');
call dolt_checkout('-b', 'feature-branch');
Expand Down
Loading

0 comments on commit 90f31d3

Please sign in to comment.