Skip to content

Commit

Permalink
Fixed a bug in BTU, added db_test file.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Jun 16, 2010
1 parent e220dce commit 7f4acea
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/btu
Expand Up @@ -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"
Expand Down Expand Up @@ -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'"
Expand Down
26 changes: 26 additions & 0 deletions 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

Empty file removed test/rvm/hash_test
Empty file.

0 comments on commit 7f4acea

Please sign in to comment.