Skip to content

Commit

Permalink
Finish first version of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgarciac committed Mar 3, 2019
1 parent a841c35 commit 5e5e53e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion TODO.md
@@ -1,6 +1,5 @@
# TODO

- Write tests
- Support TOML as an input format for documents
- Support arbitrary strings as field names
- Display help message when wrong number of arguments
17 changes: 17 additions & 0 deletions tests/tests
Expand Up @@ -71,7 +71,24 @@ testQueryInequality(){
assertEquals "Failed to query <=" "2" "$result"
}

testCompoundQuery(){
id=$(../fuego add ${TEST_COLLECTION} "{\"key1\": \"key1\", \"key2\": 2}") || fail "Failed to add document"
id=$(../fuego add ${TEST_COLLECTION} "{\"key1\": \"whatever\", \"key2\": 2}") || fail "Failed to add document"

# query first on a single field
result=$(../fuego query ${TEST_COLLECTION} "key2 == 2" | jq "length")
assertEquals "Failed to query on a single key" "2" "$result"


# query first on two fields
result=$(../fuego query ${TEST_COLLECTION} "key2 == 2" "key1 == \"key1\"" | jq "length")
assertEquals "Failed to query on two keys" "1" "$result"

# query on two fields, that fail
result=$(../fuego query ${TEST_COLLECTION} "key2 == 1" "key1 == \"key1\"" | jq "length")
assertEquals "Failed to query on two keys" "0" "$result"

}


# Load shUnit2.
Expand Down

0 comments on commit 5e5e53e

Please sign in to comment.