summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-06-03 21:10:36 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-06-06 09:52:53 +1000
commitf9516d49a02facb43e2856766b6439673450fdd1 (patch)
tree06df981d0a51f55d8a749706ae7d349e6b5401ec /spec/unit
parentb5855ec1a5af2bec6c4ac35f8e6a885999b09bf9 (diff)
downloadpuppet-f9516d49a02facb43e2856766b6439673450fdd1.tar.gz
puppet-f9516d49a02facb43e2856766b6439673450fdd1.tar.xz
puppet-f9516d49a02facb43e2856766b6439673450fdd1.zip
Make sure virtual and rails query use tags when tag are searched
Up to now, when trying to match with tags: File<<| tag == 'value' |>> in fact we were querying parameters. Hopefully all the user tags are stored in parameters so it was working. But it wasn't possible to search on auto-tags (like class name). This patch makes sure searching by tag is done on tags both on the rails side and the resource side. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/parser/ast/collexpr.rb21
-rwxr-xr-xspec/unit/parser/collector.rb4
2 files changed, 23 insertions, 2 deletions
diff --git a/spec/unit/parser/ast/collexpr.rb b/spec/unit/parser/ast/collexpr.rb
index e45203492..4dfc1e97a 100755
--- a/spec/unit/parser/ast/collexpr.rb
+++ b/spec/unit/parser/ast/collexpr.rb
@@ -74,6 +74,27 @@ describe Puppet::Parser::AST::CollExpr do
end
end
+ describe "when evaluating with tags" do
+ before :each do
+ @tag = stub 'tag', :safeevaluate => 'tag'
+ @value = stub 'value', :safeevaluate => 'value'
+
+ @resource = stub 'resource'
+ @resource.stubs(:tagged?).with("value").returns(true)
+ end
+
+ it "should produce a textual representation of the expression" do
+ collexpr = ast::CollExpr.new(:test1 => @tag, :test2 => @value, :oper=>"==")
+ result = collexpr.evaluate(@scope)
+ result[0].should == "puppet_tags.name = 'value'"
+ end
+
+ it "should inspect resource tags if the query term is on tags" do
+ collexpr = ast::CollExpr.new(:test1 => @tag, :test2 => @value, :oper => "==")
+ collexpr.evaluate(@scope)[1].call(@resource).should be_true
+ end
+ end
+
[:exported,:virtual].each do |mode|
it "should check for array member equality if resource parameter is an array for == in mode #{mode}" do
array = mock 'array', :safeevaluate => "array"
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb
index 813fbb8c0..3bca564dc 100755
--- a/spec/unit/parser/collector.rb
+++ b/spec/unit/parser/collector.rb
@@ -502,10 +502,10 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co
@collector.evaluate
end
- it "should return parameter names and parameter values when querying ActiveRecord" do
+ it "should return parameter names, parameter values and tags when querying ActiveRecord" do
Puppet::Rails::Resource.stubs(:find).with { |*arguments|
options = arguments[3]
- options[:include] == {:param_values => :param_name}
+ options[:include] == {:param_values => :param_name, :puppet_tags => :resource_tags}
}.returns([])
@collector.evaluate