Skip to content

Commit

Permalink
Make single queries more fault resistant
Browse files Browse the repository at this point in the history
  • Loading branch information
mcls committed Sep 28, 2012
1 parent 80bfb3a commit 4612583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/fql/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def compose_multi_query
end

def compose_single_query
@queries[:q]
@queries[@queries.keys[0]]
end

end
Expand Down
16 changes: 10 additions & 6 deletions test/fql/query_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
require 'fql/query'

class FqlQueryTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Class, Fql::Query
end


test "can create single query without using hash" do
assert_nothing_raised do
query = Fql::Query.new "SELECT uid2 FROM friend WHERE uid1=me()"
Expand All @@ -17,16 +14,23 @@ class FqlQueryTest < ActiveSupport::TestCase
test 'multiquery gets composed properly' do
multi_query = {
all_friends: "SELECT uid2 FROM friend WHERE uid1=me()",
my_name: "SELECT name FROM user WHERE uid=me()"
my_name: "SELECT name FROM user WHERE uid=me()"
}
query = Fql::Query.new multi_query

actual = query.compose
expected = "{" +
"'all_friends':'SELECT uid2 FROM friend WHERE uid1=me()'," +
"'all_friends':'SELECT uid2 FROM friend WHERE uid1=me()'," +
"'my_name':'SELECT name FROM user WHERE uid=me()'" +
"}"

assert_equal expected, actual
end

test 'single query gets composed properly' do
query = Fql::Query.new "SELECT name FROM user WHERE uid=me()"
actual = query.compose
expected = "SELECT name FROM user WHERE uid=me()"
assert_equal expected, actual
end
end

0 comments on commit 4612583

Please sign in to comment.