Skip to content

Commit ea3256a

Browse files
committed
Added tests
1 parent 89e3100 commit ea3256a

File tree

12 files changed

+148
-61
lines changed

12 files changed

+148
-61
lines changed

backup.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,16 @@ if [ "$?" -eq 0 ]; then
248248
# Needs refactor
249249
GRANTS_SQL="select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from mysql.user WHERE user != 'root';"
250250
GRANTS_LIST=$(mysql ${MYSQL_CONN} -ANe"${GRANTS_SQL}")
251-
echo ${GRANTS_LIST} | mysql --default-character-set=utf8 --skip-comments ${MYSQL_CONN} | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 --/;/--/{x;p;x;}' > ${BACKUP_DIR}/grants.sql
252-
251+
if [ "$?" -ne 0 ]; then
252+
exitWithMsg 215 "Grants list failed"
253+
fi
254+
GRANTS_LIST=$(echo ${GRANTS_LIST} | mysql --default-character-set=utf8 --skip-comments ${MYSQL_CONN})
253255
if [ "$?" -ne 0 ]; then
254256
exitWithMsg 214 "Grants dump failed"
255257
fi
258+
echo ${GRANTS_LIST} | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 --/;/--/{x;p;x;}' > ${BACKUP_DIR}/grants.sql
259+
260+
256261
# Removes double backslashes > \\
257262
sed -i -e 's/\\\\//g' ${BACKUP_DIR}/grants.sql
258263
# echo -e ${GRANTS_SQL}

samples/empty/grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

samples/withdata0/grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

samples/withdata1/grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

samples/withdata2/createuser.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE USER 'userwd2gf'@'%' IDENTIFIED BY 'testbench';

samples/withdata2/deleteuser.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP USER 'userwd2gf'@'%';

samples/withdata2/function1.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
USE testbench;
2+
CREATE DEFINER=`root`@`%` FUNCTION `procédure de test n°2`(`entrée 1` VARCHAR(35) CHARSET cp1250) RETURNS INT(1) UNSIGNED COMMENT "procédure de test n°2" NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER RETURN 1;

samples/withdata2/grantToDB.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GRANT ALL PRIVILEGES ON mysql.db TO 'userwd2gf'@'%';

samples/withdata2/grantToUsers.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GRANT ALL PRIVILEGES ON mysql.user TO 'userwd2gf'@'%';

samples/withdata2/grants.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)