work plz, thanks

This commit is contained in:
James Cor
2022-05-23 13:54:20 -07:00
parent 1da0fabbe8
commit bdc0086b1f
3 changed files with 128 additions and 7 deletions
+127 -6
View File
@@ -11,7 +11,7 @@ make_repo() {
show_users() {
dolt sql-client --host=0.0.0.0 --port=$PORT --user=dolt <<SQL
SELECT user from mysql.user;
SELECT user from mysql.user order by user;
SQL
}
@@ -30,14 +30,13 @@ teardown() {
cd repo1
# remove mysql.db and privs.json if they exist
# remove/replace mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
start_sql_server repo1
cd ../
# expect only dolt as user
# expect only dolt user
run show_users
[ "$status" -eq 0 ]
[ "${lines[0]}" = '# Welcome to the Dolt MySQL client.' ]
@@ -49,8 +48,6 @@ teardown() {
[ "${lines[6]}" = '| dolt |' ]
[ "${lines[7]}" = '+------+' ]
cd repo1
# check that mysql.db file exists, and privs.json doesn't
run ls
[[ "$output" =~ "mysql.db" ]] || false
@@ -59,4 +56,128 @@ teardown() {
# remove mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
# leave the directory
cd ..
}
@test "0: has privs.json and no mysql.db, read from privs.json and create mysql.db" {
skiponwindows "Has dependencies that are missing on the Jenkins Windows installation."
cd repo1
# remove/replace mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
cp $BATS_TEST_DIRNAME/privs.json .
start_sql_server repo1
# expect dolt and privs_user
run show_users
[ "$status" -eq 0 ]
[ "${lines[0]}" = '# Welcome to the Dolt MySQL client.' ]
[ "${lines[1]}" = "# Statements must be terminated with ';'." ]
[ "${lines[2]}" = '# "exit" or "quit" (or Ctrl-D) to exit.' ]
[ "${lines[3]}" = '+------------+' ]
[ "${lines[4]}" = '| User |' ]
[ "${lines[5]}" = '+------------+' ]
[ "${lines[6]}" = '| dolt |' ]
[ "${lines[7]}" = '| privs_user |' ]
[ "${lines[8]}" = '+------------+' ]
# TODO: create user
# check that mysql.db and privs.json exist
run ls
[[ "$output" =~ "mysql.db" ]] || false
[[ "$output" =~ "privs.json" ]] || false
# remove mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
# leave the directory
cd ..
}
@test "0: no privs.json and has mysql.db, read from mysql.db" {
skiponwindows "Has dependencies that are missing on the Jenkins Windows installation."
cd repo1
# remove/replace mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
cp $BATS_TEST_DIRNAME/mysql.db .
start_sql_server repo1
# expect dolt and mysql_user
run show_users
[ "$status" -eq 0 ]
[ "${lines[0]}" = '# Welcome to the Dolt MySQL client.' ]
[ "${lines[1]}" = "# Statements must be terminated with ';'." ]
[ "${lines[2]}" = '# "exit" or "quit" (or Ctrl-D) to exit.' ]
[ "${lines[3]}" = '+------------+' ]
[ "${lines[4]}" = '| User |' ]
[ "${lines[5]}" = '+------------+' ]
[ "${lines[6]}" = '| dolt |' ]
[ "${lines[7]}" = '| mysql_user |' ]
[ "${lines[8]}" = '+------------+' ]
# TODO: create user
# check that mysql.db exists, and privs.json doesn't
run ls
[[ "$output" =~ "mysql.db" ]] || false
![[ "$output" =~ "privs.json" ]] || false
# remove mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
# leave the directory
cd ..
}
@test "0: has privs.json and has mysql.db, only reads from mysql.db" {
skiponwindows "Has dependencies that are missing on the Jenkins Windows installation."
cd repo1
# remove/replace mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
cp $BATS_TEST_DIRNAME/privs.json .
cp $BATS_TEST_DIRNAME/mysql.db .
start_sql_server repo1
# expect dolt and mysql_user
run show_users
[ "$status" -eq 0 ]
[ "${lines[0]}" = '# Welcome to the Dolt MySQL client.' ]
[ "${lines[1]}" = "# Statements must be terminated with ';'." ]
[ "${lines[2]}" = '# "exit" or "quit" (or Ctrl-D) to exit.' ]
[ "${lines[3]}" = '+------------+' ]
[ "${lines[4]}" = '| User |' ]
[ "${lines[5]}" = '+------------+' ]
[ "${lines[6]}" = '| dolt |' ]
[ "${lines[7]}" = '| mysql_user |' ]
[ "${lines[8]}" = '+------------+' ]
# TODO: create user
# check that mysql.db exists, and privs.json doesn't
run ls
[[ "$output" =~ "mysql.db" ]] || false
[[ "$output" =~ "privs.json" ]] || false
# remove mysql.db and privs.json if they exist
rm -f mysql.db
rm -f privs.json
# leave the directory
cd ..
}
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"Users":[{"User":"root","Host":"%","PrivilegeSet":{"GlobalStatic":["SELECT","INSERT","UPDATE","DELETE","CREATE","DROP","RELOAD","SHUTDOWN","PROCESS","FILE","GRANT","REFERENCES","INDEX","ALTER","SHOW DATABASES","SUPER","CREATE TEMPORARY TABLES","LOCK TABLES","EXECUTE","REPLICATION SLAVE","REPLICATION CLIENT","CREATE VIEW","SHOW VIEW","CREATE ROUTINE","ALTER ROUTINE","CREATE USER","EVENT","TRIGGER","CREATE TABLESPACE","CREATE ROLE","DROP ROLE"],"Databases":[]},"Plugin":"mysql_native_password","Password":"","PasswordLastChanged":"1970-01-01T00:00:01Z","Locked":false,"Attributes":null,"IsRole":false},{"User":"privs_user","Host":"%","PrivilegeSet":{"GlobalStatic":["SELECT","INSERT","UPDATE","DELETE","CREATE","DROP","RELOAD","SHUTDOWN","PROCESS","FILE","GRANT","REFERENCES","INDEX","ALTER","SHOW DATABASES","SUPER","CREATE TEMPORARY TABLES","LOCK TABLES","EXECUTE","REPLICATION SLAVE","REPLICATION CLIENT","CREATE VIEW","SHOW VIEW","CREATE ROUTINE","ALTER ROUTINE","CREATE USER","EVENT","TRIGGER","CREATE TABLESPACE","CREATE ROLE","DROP ROLE"],"Databases":[]},"Plugin":"mysql_native_password","Password":"","PasswordLastChanged":"1970-01-01T00:00:01Z","Locked":false,"Attributes":null,"IsRole":false}],"Roles":[]}
{"Users":[{"User":"privs_user","Host":"","PrivilegeSet":{"GlobalStatic":[],"Databases":[]},"Plugin":"mysql_native_password","Password":"","PasswordLastChanged":"2022-05-23T20:37:32.5382927Z","Locked":false,"Attributes":null,"IsRole":false},{"User":"dolt","Host":"%","PrivilegeSet":{"GlobalStatic":["SELECT","INSERT","UPDATE","DELETE","CREATE","DROP","RELOAD","SHUTDOWN","PROCESS","FILE","GRANT","REFERENCES","INDEX","ALTER","SHOW DATABASES","SUPER","CREATE TEMPORARY TABLES","LOCK TABLES","EXECUTE","REPLICATION SLAVE","REPLICATION CLIENT","CREATE VIEW","SHOW VIEW","CREATE ROUTINE","ALTER ROUTINE","CREATE USER","EVENT","TRIGGER","CREATE TABLESPACE","CREATE ROLE","DROP ROLE"],"Databases":[]},"Plugin":"mysql_native_password","Password":"","PasswordLastChanged":"1970-01-01T00:00:01Z","Locked":false,"Attributes":null,"IsRole":false}],"Roles":[]}