summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-30 16:47:40 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-31 13:03:08 -0700
commitf850da7bef6ed732b7b8009d0d0841694d8914bc (patch)
treedf28811df45c0de0dddfc866188d3e6533411345
parent5fb94bf7bd7d22fd3a1cff22f5861b0fbf32adb1 (diff)
downloadchef-f850da7bef6ed732b7b8009d0d0841694d8914bc.tar.gz
add a few tests
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/search/query.rb2
-rw-r--r--spec/unit/search/query_spec.rb23
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index 7e70584f30..6f494819ba 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -63,7 +63,7 @@ class Chef
validate_type(type)
args_h = hashify_args(*args)
- if args_h.key?(:fuzz)
+ if args_h[:fuzz]
if type == :node
query = fuzzify_node_query(query)
end
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index 0837410b3c..95221870d5 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -237,6 +237,27 @@ describe Chef::Search::Query do
end
end
+ it "fuzzifies node searches when fuzz is set" do
+ expect(rest).to receive(:get).with(
+ "search/node?q=tags:*free.messi*%20OR%20roles:*free.messi*%20OR%20fqdn:*free.messi*%20OR%20addresses:*free.messi*%20OR%20policy_name:*free.messi*%20OR%20policy_group:*free.messi*&start=0"
+ ).and_return(response)
+ query.search(:node, "free.messi", fuzz: true)
+ end
+
+ it "does not fuzzify node searches when fuzz is not set" do
+ expect(rest).to receive(:get).with(
+ "search/node?q=free.messi&start=0"
+ ).and_return(response)
+ query.search(:node, "free.messi")
+ end
+
+ it "does not fuzzify client searches" do
+ expect(rest).to receive(:get).with(
+ "search/client?q=messi&start=0"
+ ).and_return(response)
+ query.search(:client, "messi", fuzz: true)
+ end
+
context "when :filter_result is provided as a result" do
include_context "filtered search" do
let(:filter_key) { :filter_result }