summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-08-02 17:53:09 (GMT)
committerCătălin Badea <catalin.badea392@gmail.com>2012-08-11 15:59:13 (GMT)
commit32df43a469e883898d23d45ef5dab79c02d3e179 (patch)
tree90e2368bcfea2b570e6a2a3e0f5f8c65224aab82
parent716f6262dd8dce6aae8822355a863433d09dcc97 (diff)
downloadswift-contrib-32df43a469e883898d23d45ef5dab79c02d3e179.zip
swift-contrib-32df43a469e883898d23d45ef5dab79c02d3e179.tar.bz2
add test script.
-rwxr-xr-xtest_date.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/test_date.sh b/test_date.sh
new file mode 100755
index 0000000..546aacf
--- /dev/null
+++ b/test_date.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+if [ $# -ne 1 ]
+then
+ echo "usage: $0 name@domain.sth"
+ exit -1;
+fi
+echo "populating db for user $1"
+
+dbName='testDB.db'
+sqlite="sqlite3"
+JIDs=('andrew@gmail.com' 'john@gmail.com' 'carol@redcode.com' 'nick@foss.org' 'james@random.org')
+selfJID=$1
+randomWords=('cheese' 'house' 'berry' 'tree' 'glass' 'door' 'music' 'work')
+
+baseStatement="INSERT INTO messages('message', 'fromBare', 'fromResource', 'toBare', 'toResource', 'type', 'time') VALUES("
+baseMessage="Message from: "
+
+firstDay=1
+lastDay=8
+month=6
+
+$sqlite -line $dbName "CREATE TABLE IF NOT EXISTS messages('message' STRING, 'fromBare' INTEGER, 'fromResource' STRING, 'toBare' INTEGER, 'toResource' STRING, 'type' INTEGER, 'time' INTEGER, 'offset' INTEGER);"
+
+$sqlite -line $dbName "CREATE TABLE IF NOT EXISTS jids('id' INTEGER PRIMARY KEY ASC AUTOINCREMENT, 'jid' STRING UNIQUE NOT NULL);"
+
+$sqlite -line $dbName "INSERT INTO jids('jid') VALUES('$selfJID');"
+
+for (( id=2; id<${#JIDs[@]} + 2; id++ ))
+do
+ echo $id
+ $sqlite -line $dbName "INSERT INTO jids('jid') VALUES('${JIDs[$((id - 2))]}');"
+ for (( i=$firstDay; i<lastDay; i++ ))
+ do
+ for (( r=0; r < $((RANDOM%29)); r++ ))
+ do
+ for (( c=0; c < $((RANDOM%12)); c++ ))
+ do
+ date=$(date --date="$month/$i/12" +%s)
+ message="$baseMessage$month/$i/12:$c ${randomWords[$((RANDOM%100))]}"
+ statement="$baseStatement '$message', $id, '', 1, '', 0, $((date + c * 30 + 3600 * 8)));"
+ $sqlite -line $dbName "$statement"
+ done
+
+ for (( c=0; c < $((RANDOM%12)); c++ ))
+ do
+ date=$(date --date="$month/$i/12" +%s)
+ message="$baseMessage$month/$i/12:$c ${randomWords[$((RANDOM%100))]}"
+ statement="$baseStatement '$message', 1, '', $id, '', 0, $((date + c * 60 + 3600 * 8)));"
+ $sqlite -line $dbName "$statement"
+ done
+ done
+ done
+done