summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Gleeson <mgleeson@atlassian.com>2013-09-25 17:50:42 -0700
committerMatt Gleeson <mgleeson@atlassian.com>2013-09-25 17:50:42 -0700
commit79c74e3bc87807a06c0b68156602586c6ef4f097 (patch)
treeb19e66fa52d6e585925aaf2f012f8e2e0abc2838
parent23ab1444189e2b6617d78b305e873f3d0cc1a8f8 (diff)
downloadchef-zero-79c74e3bc87807a06c0b68156602586c6ef4f097.tar.gz
smoke tests for search
-rw-r--r--spec/search_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/search_spec.rb b/spec/search_spec.rb
new file mode 100644
index 0000000..aa222fa
--- /dev/null
+++ b/spec/search_spec.rb
@@ -0,0 +1,27 @@
+require 'chef_zero/solr/solr_parser'
+require 'chef_zero/solr/solr_doc'
+
+#p = ChefZero::Solr::SolrParser.new('chef_environment:prod AND roles:redis_history_server AND -redis_slaveof:[a TO z]')
+
+describe ChefZero::Solr::SolrParser do
+ let (:all_docs) do
+ docs = []
+ [{'foo' => 1},
+ {'foo' => 7}].each_with_index do |h, i|
+ docs.push ChefZero::Solr::SolrDoc.new(h, i)
+ end
+ docs
+ end
+
+ it "handles terms" do
+ q = ChefZero::Solr::SolrParser.new('foo:7').parse
+ results = all_docs.select {|doc| q.matches_doc?(doc) }
+ results.size.should eq(1)
+ end
+
+ it "handles ranges" do
+ q = ChefZero::Solr::SolrParser.new('foo:[1 TO 5]').parse
+ results = all_docs.select {|doc| q.matches_doc?(doc) }
+ results.size.should eq(1)
+ end
+end