[Dbconfig-common-changes] [dbconfig-common] r434 - trunk/test
Sean Finney
seanius at alioth.debian.org
Sun Mar 30 18:40:09 UTC 2008
Author: seanius
Date: 2008-03-30 18:40:09 +0000 (Sun, 30 Mar 2008)
New Revision: 434
Added:
trunk/test/basic.sh
trunk/test/mockdb.sh
Removed:
trunk/test/basic.ts
trunk/test/mockdb.ts
Modified:
trunk/test/runtests.sh
Log:
rename the test suites with .sh
Copied: trunk/test/basic.sh (from rev 433, trunk/test/basic.ts)
===================================================================
--- trunk/test/basic.sh (rev 0)
+++ trunk/test/basic.sh 2008-03-30 18:40:09 UTC (rev 434)
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+. `dirname $0`/functions
+. ${_dbc_root}/internal/common
+
+test_dbc_logline(){
+ local output
+
+ # test echoing one line to user and logfile
+ output=`dbc_logline foo 2>&1 >/dev/null`
+ assertTrue "dbc_logline foo returned error" $?
+ assertEquals foo. "$output"
+ assertFilesEqual $_dbc_logfile ./data/dbc_logline.simple.txt
+
+ # test that a second line is logged appropriately
+ dbc_logline bar >/dev/null 2>&1
+ assertFilesEqual $_dbc_logfile ./data/dbc_logline.twolines.txt
+
+ # test that multiple arguments are logged appropriately
+ cat /dev/null > $_dbc_logfile
+ output=`dbc_logline foo bar 2>&1 >/dev/null`
+ assertTrue "dbc_logline foo bar returned error" $?
+ assertEquals "foo bar." "$output"
+ assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
+
+ # assure that quoting and escaping are handled properly
+ output=`dbc_logline "\"foobar's\ttab\"" 2>&1 >/dev/null`
+ assertTrue "dbc_logline (with escaping) returned error" $?
+ assertEquals "\"foobar's tab\"." "$output"
+}
+
+test_dbc_logpart(){
+ # make sure it properly logs partial lines
+ dbc_logpart foo >/dev/null 2>&1
+ assertTrue "dbc_logpart foo returned error" $?
+ assertFilesEqual $_dbc_logfile ./data/dbc_logpart.noeol.txt
+
+ # ...and that it completes them with the next logline.
+ dbc_logline bar >/dev/null 2>&1
+ assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
+}
+
+test_dbc_debug(){
+ local olddebug
+ if [ "${dbc_debug:-}" ]; then olddebug=$dbc_debug; else olddebug=""; fi
+
+ # make sure it doesn't do anything by default
+ dbc_debug=""
+ _dbc_debug foo bar >/dev/null 2>&1
+ assertTrue "_dbc_debug foo bar returned error" $?
+ assertFilesEqual $_dbc_logfile /dev/null
+
+ # ...and that it completes them with the next logline.
+ dbc_debug=1
+ _dbc_debug foo bar >/dev/null 2>&1
+ assertTrue "_dbc_debug foo bar returned error" $?
+ assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
+
+ dbc_debug=$olddebug
+}
+
+test_dbc_mktemp(){
+ local t
+ # try making a temp file w/out arguments
+ t=`dbc_mktemp`
+ assertTrue "dbc_mktemp (no args) failed" $?
+ assertTrue "dbc_mktemp (no args) file $t nonexistant" '[ -f "$t" ]'
+ assertTrue "dbc_mktemp (no args) file $t nonempty" '[ ! -s "$t" ]'
+ rm -f "$t"
+
+ # try making a temp file with arguments
+ t=`dbc_mktemp foo.XXXXXX`
+ assertTrue "dbc_mktemp (no args) failed" $?
+ assertTrue "dbc_mktemp (no args) file $t nonexistant" '[ -f "$t" ]'
+ assertTrue "dbc_mktemp (no args) file $t nonempty" '[ ! -s "$t" ]'
+ rm -f "$t"
+}
+
+. /usr/share/shunit2/shunit2
Deleted: trunk/test/basic.ts
===================================================================
--- trunk/test/basic.ts 2008-03-30 18:29:48 UTC (rev 433)
+++ trunk/test/basic.ts 2008-03-30 18:40:09 UTC (rev 434)
@@ -1,79 +0,0 @@
-#!/bin/sh
-
-. `dirname $0`/functions
-. ${_dbc_root}/internal/common
-
-test_dbc_logline(){
- local output
-
- # test echoing one line to user and logfile
- output=`dbc_logline foo 2>&1 >/dev/null`
- assertTrue "dbc_logline foo returned error" $?
- assertEquals foo. "$output"
- assertFilesEqual $_dbc_logfile ./data/dbc_logline.simple.txt
-
- # test that a second line is logged appropriately
- dbc_logline bar >/dev/null 2>&1
- assertFilesEqual $_dbc_logfile ./data/dbc_logline.twolines.txt
-
- # test that multiple arguments are logged appropriately
- cat /dev/null > $_dbc_logfile
- output=`dbc_logline foo bar 2>&1 >/dev/null`
- assertTrue "dbc_logline foo bar returned error" $?
- assertEquals "foo bar." "$output"
- assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
-
- # assure that quoting and escaping are handled properly
- output=`dbc_logline "\"foobar's\ttab\"" 2>&1 >/dev/null`
- assertTrue "dbc_logline (with escaping) returned error" $?
- assertEquals "\"foobar's tab\"." "$output"
-}
-
-test_dbc_logpart(){
- # make sure it properly logs partial lines
- dbc_logpart foo >/dev/null 2>&1
- assertTrue "dbc_logpart foo returned error" $?
- assertFilesEqual $_dbc_logfile ./data/dbc_logpart.noeol.txt
-
- # ...and that it completes them with the next logline.
- dbc_logline bar >/dev/null 2>&1
- assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
-}
-
-test_dbc_debug(){
- local olddebug
- if [ "${dbc_debug:-}" ]; then olddebug=$dbc_debug; else olddebug=""; fi
-
- # make sure it doesn't do anything by default
- dbc_debug=""
- _dbc_debug foo bar >/dev/null 2>&1
- assertTrue "_dbc_debug foo bar returned error" $?
- assertFilesEqual $_dbc_logfile /dev/null
-
- # ...and that it completes them with the next logline.
- dbc_debug=1
- _dbc_debug foo bar >/dev/null 2>&1
- assertTrue "_dbc_debug foo bar returned error" $?
- assertFilesEqual $_dbc_logfile ./data/dbc_logline.twowords.txt
-
- dbc_debug=$olddebug
-}
-
-test_dbc_mktemp(){
- local t
- # try making a temp file w/out arguments
- t=`dbc_mktemp`
- assertTrue "dbc_mktemp (no args) failed" $?
- assertTrue "dbc_mktemp (no args) file $t nonexistant" '[ -f "$t" ]'
- assertTrue "dbc_mktemp (no args) file $t nonempty" '[ ! -s "$t" ]'
- rm -f "$t"
-
- # try making a temp file with arguments
- t=`dbc_mktemp foo.XXXXXX`
- assertTrue "dbc_mktemp (no args) failed" $?
- assertTrue "dbc_mktemp (no args) file $t nonexistant" '[ -f "$t" ]'
- assertTrue "dbc_mktemp (no args) file $t nonempty" '[ ! -s "$t" ]'
- rm -f "$t"
-}
-
-. /usr/share/shunit2/shunit2
Copied: trunk/test/mockdb.sh (from rev 433, trunk/test/mockdb.ts)
===================================================================
--- trunk/test/mockdb.sh (rev 0)
+++ trunk/test/mockdb.sh 2008-03-30 18:40:09 UTC (rev 434)
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+dbc_dbname="testdbname"
+dbc_dbadmin="testadmin"
+dbc_dbadmpass="testadmpass"
+dbc_dbserver="testserver"
+dbc_dbport="testport"
+
+# get some common functions
+. `dirname "$0"`/functions
+. ${_dbc_root}/internal/mysql
+
+test_generate_mycnf(){
+ local cnf DIFF
+
+ DIFF='diff -b -u -I "^# generated on"'
+
+ cnf=`_dbc_generate_mycnf`
+ assertTrue "_dbc_generate_mycnf returned error" $?
+ assertFilesEqual ./data/generate_mycnf.txt "$cnf"
+ rm -f "$cnf"
+}
+
+test_mysql_check_connect(){
+ _dbc_mysql_check_connect
+ assertTrue "mysql_check_connect failed" $?
+ subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
+ assertFilesEqual ./data/mysql_check_connect.txt "$mockup_cmdline"
+ assertFileEmpty "unexpected input to mysql_check_connect" "$mockup_inlog"
+}
+
+test_dbc_mysql_exec_file(){
+ local _dbc_nodb sql
+
+ sql=`mktemp -t`
+
+ # basic test
+ dbc_mysql_exec_file "$sql" >/dev/null
+ assertTrue "dbc_mysql_exec_file (withdb) failed" $?
+ subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
+ assertFilesEqual ./data/dbc_mysql_exec_file.withdb.txt "$mockup_cmdline"
+
+ # test with non-existing sqlfile
+ dbc_mysql_exec_file "does not exist.sql" >/dev/null
+ assertFalse "dbc_mysql_exec_file (withdb) should have failed" $?
+ subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
+ assertFilesEqual ./data/dbc_mysql_exec_file.withdb.txt "$mockup_cmdline"
+
+ # same as before, but with _dbc_nodb set
+ _dbc_nodb=yes
+ dbc_mysql_exec_file "$sql" >/dev/null
+ assertTrue "dbc_mysql_exec_file (nodb) failed" $?
+ subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
+ assertFilesEqual ./data/dbc_mysql_exec_file.nodb.txt "$mockup_cmdline"
+
+ dbc_mysql_exec_file "does not exist.sql" >/dev/null
+ assertFalse "dbc_mysql_exec_file (nodb) should have failed" $?
+ subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
+ assertFilesEqual ./data/dbc_mysql_exec_file.nodb.txt "$mockup_cmdline"
+
+ rm -f "$sql"
+}
+
+test_mysql_exec_command(){
+ dbc_mysql_exec_command "select * from foo where bar = 1"
+ assertTrue "dbc_mysql_exec_command failed" $?
+ assertFilesEqual ./data/mysql_exec_command.sql.txt "$mockup_inlog"
+}
+
+test_dbc_mysql_check_database(){
+ local mockup_stdout
+ export mockup_stdout=./data/dbc_mysql_check_database.exists.stdout.txt
+
+ _dbc_mysql_check_database "$dbc_dbname"
+ assertTrue "_dbc_mysql_check_database failed to find db" $?
+
+ mockup_stdout=./data/dbc_mysql_check_database.missing.stdout.txt
+ _dbc_mysql_check_database "$dbc_dbname"
+ assertFalse "_dbc_mysql_check_database shouldn't have found db" $?
+}
+
+. /usr/share/shunit2/shunit2
Deleted: trunk/test/mockdb.ts
===================================================================
--- trunk/test/mockdb.ts 2008-03-30 18:29:48 UTC (rev 433)
+++ trunk/test/mockdb.ts 2008-03-30 18:40:09 UTC (rev 434)
@@ -1,82 +0,0 @@
-#!/bin/sh
-
-dbc_dbname="testdbname"
-dbc_dbadmin="testadmin"
-dbc_dbadmpass="testadmpass"
-dbc_dbserver="testserver"
-dbc_dbport="testport"
-
-# get some common functions
-. `dirname "$0"`/functions
-. ${_dbc_root}/internal/mysql
-
-test_generate_mycnf(){
- local cnf DIFF
-
- DIFF='diff -b -u -I "^# generated on"'
-
- cnf=`_dbc_generate_mycnf`
- assertTrue "_dbc_generate_mycnf returned error" $?
- assertFilesEqual ./data/generate_mycnf.txt "$cnf"
- rm -f "$cnf"
-}
-
-test_mysql_check_connect(){
- _dbc_mysql_check_connect
- assertTrue "mysql_check_connect failed" $?
- subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
- assertFilesEqual ./data/mysql_check_connect.txt "$mockup_cmdline"
- assertFileEmpty "unexpected input to mysql_check_connect" "$mockup_inlog"
-}
-
-test_dbc_mysql_exec_file(){
- local _dbc_nodb sql
-
- sql=`mktemp -t`
-
- # basic test
- dbc_mysql_exec_file "$sql" >/dev/null
- assertTrue "dbc_mysql_exec_file (withdb) failed" $?
- subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
- assertFilesEqual ./data/dbc_mysql_exec_file.withdb.txt "$mockup_cmdline"
-
- # test with non-existing sqlfile
- dbc_mysql_exec_file "does not exist.sql" >/dev/null
- assertFalse "dbc_mysql_exec_file (withdb) should have failed" $?
- subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
- assertFilesEqual ./data/dbc_mysql_exec_file.withdb.txt "$mockup_cmdline"
-
- # same as before, but with _dbc_nodb set
- _dbc_nodb=yes
- dbc_mysql_exec_file "$sql" >/dev/null
- assertTrue "dbc_mysql_exec_file (nodb) failed" $?
- subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
- assertFilesEqual ./data/dbc_mysql_exec_file.nodb.txt "$mockup_cmdline"
-
- dbc_mysql_exec_file "does not exist.sql" >/dev/null
- assertFalse "dbc_mysql_exec_file (nodb) should have failed" $?
- subst_tmpfile dbconfig-common_my.cnf.XXXXXX "$mockup_cmdline"
- assertFilesEqual ./data/dbc_mysql_exec_file.nodb.txt "$mockup_cmdline"
-
- rm -f "$sql"
-}
-
-test_mysql_exec_command(){
- dbc_mysql_exec_command "select * from foo where bar = 1"
- assertTrue "dbc_mysql_exec_command failed" $?
- assertFilesEqual ./data/mysql_exec_command.sql.txt "$mockup_inlog"
-}
-
-test_dbc_mysql_check_database(){
- local mockup_stdout
- export mockup_stdout=./data/dbc_mysql_check_database.exists.stdout.txt
-
- _dbc_mysql_check_database "$dbc_dbname"
- assertTrue "_dbc_mysql_check_database failed to find db" $?
-
- mockup_stdout=./data/dbc_mysql_check_database.missing.stdout.txt
- _dbc_mysql_check_database "$dbc_dbname"
- assertFalse "_dbc_mysql_check_database shouldn't have found db" $?
-}
-
-. /usr/share/shunit2/shunit2
Modified: trunk/test/runtests.sh
===================================================================
--- trunk/test/runtests.sh 2008-03-30 18:29:48 UTC (rev 433)
+++ trunk/test/runtests.sh 2008-03-30 18:40:09 UTC (rev 434)
@@ -1,7 +1,7 @@
#! /bin/sh
cd "`dirname $0`"
-for t in basic.ts mockdb.ts; do
+for t in basic.sh mockdb.sh; do
printf "# # #\n# # # Test: $t\n# # #\n"
printf "# #\n# # Shell: bash\n# #\n"
bash $t
More information about the Dbconfig-common-changes
mailing list