aboutsummaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2020-11-28 19:42:22 +0100
committerMarius Bakke <marius@gnu.org>2020-11-28 19:51:40 +0100
commit97c4fd21bdd7470da91c4a47aab1d6357bdc8080 (patch)
tree130bbed121af4c47c0084052930955325ab2d6de /gnu/tests
parente20388ad7f94e72a7a71272a742031fb5c1fbb4b (diff)
downloadguix-97c4fd21bdd7470da91c4a47aab1d6357bdc8080.tar.gz
guix-97c4fd21bdd7470da91c4a47aab1d6357bdc8080.zip
services: MySQL: Add more tests.
* gnu/tests/databases.scm (run-mysql-test): Try creating a database and inserting data.
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/databases.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm
index dd1af1dbcc..31d5ae4c6a 100644
--- a/gnu/tests/databases.scm
+++ b/gnu/tests/databases.scm
@@ -315,6 +315,45 @@
(test-assert "mysql_upgrade completed"
(wait-for-file "/var/lib/mysql/mysql_upgrade_info" marionette))
+ (test-eq "create database"
+ 0
+ (marionette-eval
+ '(begin
+ (system* #$(file-append mariadb "/bin/mysql")
+ "-e" "CREATE DATABASE guix;"))
+ marionette))
+
+ (test-eq "create table"
+ 0
+ (marionette-eval
+ '(begin
+ (system*
+ #$(file-append mariadb "/bin/mysql") "guix"
+ "-e" "CREATE TABLE facts (id INT, data VARCHAR(12));"))
+ marionette))
+
+ (test-eq "insert data"
+ 0
+ (marionette-eval
+ '(begin
+ (system* #$(file-append mariadb "/bin/mysql") "guix"
+ "-e" "INSERT INTO facts VALUES (1, 'awesome')"))
+ marionette))
+
+ (test-equal "retrieve data"
+ "awesome\n"
+ (marionette-eval
+ '(begin
+ (use-modules (ice-9 popen))
+ (let* ((port (open-pipe*
+ OPEN_READ
+ #$(file-append mariadb "/bin/mysql") "guix"
+ "-NB" "-e" "SELECT data FROM facts WHERE id=1;"))
+ (output (get-string-all port)))
+ (close-pipe port)
+ output))
+ marionette))
+
(test-end)
(exit (= (test-runner-fail-count (test-runner-current)) 0)))))