Permalink
Browse files

Fixed a bug in BTU, added db_test file.

  • Loading branch information...
1 parent e220dce commit 7f4acea9e2981783d2faeed8f5cfcfabd2af6db0 @wayneeseguin wayneeseguin committed Jun 16, 2010
Showing with 30 additions and 3 deletions.
  1. +4 −3 test/btu
  2. +26 −0 test/rvm/db_test
  3. 0 test/rvm/hash_test
View
7 test/btu
@@ -52,7 +52,7 @@ heat() {
}
assert() {
- key=$1 ; first=$2 ; second=$3
+ key="$1" ; first="$2" ; second="$3"
assertion="__btu_assert_${key} \"$first\" \"$second\""
btu_push __btu_assertions $assertion
eval "$assertion"
@@ -179,15 +179,16 @@ __btu_assert_no_match() {
__btu_assert_file_contains() {
regex=$(echo "$1" | sed 's/\//\\\//g')
- if [[ ! -z "$(awk "/$regex/" "$2" | cat)" ]] ; then
+ if [[ ! -z "$(awk "/$regex/" "$2")" ]] ; then
__btu_log "pass" "/$regex/ $(scripts/color "green")is in$(scripts/color "none") '$2'"
else
__btu_log "fail" "/$regex/ $(scripts/color "red")is not in$(scripts/color "none") '$2'"
fi ; return $?
}
+
__btu_assert_file_does_not_contain() {
regex=$(echo "$1" | sed 's/\//\\\//g')
- if [[ ! -z "$(awk "/$regex/" "$2" | cat)" ]] ; then
+ if [[ -z "$(awk '/'$regex'/' "$2")" ]] ; then
__btu_log "pass" "/$regex/ $(scripts/color "green")is not in$(scripts/color "none") '$2'"
else
__btu_log "fail" "/$regex/ $(scripts/color "red")is in$(scripts/color "none") '$2'"
View
26 test/rvm/db_test
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+source ./test/setup
+initialize_rvm
+
+database_file="/tmp/$$.db"
+
+heat './scripts/db '$database_file' "akey" "avalue" 2>/dev/null'
+assert number_eq 1 $result
+# TODO: assert error 'Database file $database_file does not exist.'
+
+touch $database_file
+
+heat './scripts/db '$database_file' "akey" "avalue"'
+assert file_contains 'akey=avalue' $database_file
+
+heat 'value=$(./scripts/db '$database_file' "akey")'
+assert string_eq "$value" "avalue"
+
+heat './scripts/db '$database_file' "akey" delete'
+assert file_does_not_contain 'akey=avalue' $database_file
+
+rm -f $database_file # Cleanup, aisle 3!
+
+if [[ -z "$rvm_teset_suite_flag" ]] ; then btu_summary ; fi
+
View
0 test/rvm/hash_test
No changes.

0 comments on commit 7f4acea

Please sign in to comment.