summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-02-06 11:34:16 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit0d704686b923c7827b9fe16f20d4f8722c125d88 (patch)
treebc410cb6b30e8f56b6a8abae93ee8e195febb485 /test
parentad93d0e442d4e4eff69bb3f444b2eee70a95dfa8 (diff)
downloadpuppet-0d704686b923c7827b9fe16f20d4f8722c125d88.tar.gz
puppet-0d704686b923c7827b9fe16f20d4f8722c125d88.tar.xz
puppet-0d704686b923c7827b9fe16f20d4f8722c125d88.zip
Finishing renaming :params to :parameters internally
I had only done this partway, because it seemed easier, but not surprisingly, it ended up being more complex. In addition to those renames, this commit includes fixes to whatever tests I needed to fix to confirm that things were again working. I think most of these broken tests have been broken for a while. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/ast.rb55
-rwxr-xr-xtest/language/functions.rb11
-rwxr-xr-xtest/language/scope.rb55
-rwxr-xr-xtest/language/snippets.rb4
-rw-r--r--test/lib/puppettest/parsertesting.rb16
-rw-r--r--test/lib/puppettest/railstesting.rb2
-rw-r--r--test/lib/puppettest/resourcetesting.rb8
-rw-r--r--test/lib/puppettest/support/collection.rb29
8 files changed, 22 insertions, 158 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb
index 916c34d45..a4d4d8773 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -6,12 +6,10 @@ require 'puppettest'
require 'puppet/parser/parser'
require 'puppettest/resourcetesting'
require 'puppettest/parsertesting'
-require 'puppettest/support/collection'
class TestAST < Test::Unit::TestCase
include PuppetTest::ParserTesting
include PuppetTest::ResourceTesting
- include PuppetTest::Support::Collection
def test_if
scope = mkscope
@@ -56,41 +54,13 @@ class TestAST < Test::Unit::TestCase
ref = resourceoverride("file", "/yayness", "owner" => "blah", "group" => "boo")
end
- Puppet::Parser::Resource.expects(:new).with { |type, title, o| o.is_a?(Hash) }.returns(:override)
- scope.compiler.expects(:add_override).with(:override)
+ scope.compiler.expects(:add_override).with { |res| res.is_a?(Puppet::Parser::Resource) }
ret = nil
assert_nothing_raised do
ret = ref.evaluate scope
end
- assert_equal(:override, ret, "Did not return override")
- end
-
- # make sure our resourcedefaults ast object works correctly.
- def test_resourcedefaults
- scope = mkscope
-
- # Now make some defaults for files
- args = {:source => "/yay/ness", :group => "yayness"}
- assert_nothing_raised do
- obj = defaultobj "file", args
- obj.evaluate scope
- end
-
- hash = nil
- assert_nothing_raised do
- hash = scope.lookupdefaults("File")
- end
-
- hash.each do |name, value|
- assert_instance_of(Symbol, name) # params always convert
- assert_instance_of(Puppet::Parser::Resource::Param, value)
- end
-
- args.each do |name, value|
- assert(hash[name], "Did not get default %s" % name)
- assert_equal(value, hash[name].value)
- end
+ assert_instance_of(Puppet::Parser::Resource, ret, "Did not return override")
end
def test_collection
@@ -114,25 +84,4 @@ class TestAST < Test::Unit::TestCase
colls = scope.compiler.instance_variable_get("@collections")
assert_equal([ret], colls, "Did not store collector in config's collection list")
end
-
- def test_virtual_collexp
- scope = mkscope
-
- # make a resource
- resource = mkresource(:type => "file", :title => "/tmp/testing",
- :scope => scope, :params => {:owner => "root", :group => "bin", :mode => "644"})
-
- run_collection_queries(:virtual) do |string, result, query|
- code = nil
- assert_nothing_raised do
- str, code = query.evaluate scope
- end
-
- assert_instance_of(Proc, code)
- assert_nothing_raised do
- assert_equal(result, code.call(resource),
- "'#{string}' failed")
- end
- end
- end
end
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 70605f8f6..8797a4644 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -382,16 +382,13 @@ class TestLangFunctions < Test::Unit::TestCase
end
def test_search
- parser = mkparser
- scope = mkscope(:parser => parser)
+ scope = mkscope
- fun = parser.newdefine("yay::ness")
- foo = parser.newdefine("foo::bar")
+ fun = scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "yay::ness")
+ foo = scope.known_resource_types.add Puppet::Resource::Type.new(:definition, "foo::bar")
search = Puppet::Parser::Functions.function(:search)
- assert_nothing_raised do
- scope.function_search(["foo", "yay"])
- end
+ scope.function_search(["foo", "yay"])
ffun = ffoo = nil
assert_nothing_raised("Search path change did not work") do
diff --git a/test/language/scope.rb b/test/language/scope.rb
index b1ba63de4..17e97ecfb 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -118,53 +118,6 @@ class TestScope < Test::Unit::TestCase
assert_equal(top, sub.parent, "Did not find parent scope on second call")
end
- def test_includefunction
- parser = mkparser
- scope = mkscope :parser => parser
-
- myclass = parser.newclass "myclass"
- otherclass = parser.newclass "otherclass"
-
- function = Puppet::Parser::AST::Function.new(
- :name => "include",
- :ftype => :statement,
- :arguments => AST::ASTArray.new(
- :children => [nameobj("myclass"), nameobj("otherclass")]
- )
- )
-
- assert_nothing_raised do
- function.evaluate scope
- end
-
- scope.compiler.send(:evaluate_generators)
-
- [myclass, otherclass].each do |klass|
- assert(scope.compiler.class_scope(klass),
- "%s was not set" % klass.name)
- end
- end
-
- def test_definedfunction
- Puppet::Parser::Functions.function(:defined)
- parser = mkparser
- %w{one two}.each do |name|
- parser.newdefine name
- end
-
- scope = mkscope :parser => parser
-
- assert_nothing_raised {
- %w{one two file user}.each do |type|
- assert(scope.function_defined([type]),
- "Class #{type} was not considered defined")
- end
-
- assert(!scope.function_defined(["nopeness"]),
- "Class 'nopeness' was incorrectly considered defined")
- }
- end
-
# Make sure we know what we consider to be truth.
def test_truth
assert_equal(true, Puppet::Parser::Scope.true?("a string"),
@@ -179,23 +132,19 @@ class TestScope < Test::Unit::TestCase
"undef considered true")
end
- # Verify that we recursively mark as exported the results of collectable
- # components.
def test_virtual_definitions_do_not_get_evaluated
- config = mkcompiler
parser = mkparser
+ config = mkcompiler
# Create a default source
parser.newclass("")
config.topscope.source = parser.known_resource_types.hostclass("")
# And a scope resource
- scope_res = Puppet::Parser::Resource.new(:file, "/file", :scope => "scope", :source => "source")
+ scope_res = Puppet::Parser::Resource.new(:file, "/file", :scope => config.topscope)
config.topscope.resource = scope_res
args = AST::ASTArray.new(
- :file => tempfile(),
- :line => rand(100),
:children => [nameobj("arg")]
)
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 6aa202640..f083c355c 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -123,7 +123,7 @@ class TestSnippets < Test::Unit::TestCase
end
def randeach(type)
- [:properties, :metaparams, :params].collect { |thing|
+ [:properties, :metaparams, :parameters].collect { |thing|
randthing(thing,type)
}
end
@@ -206,7 +206,7 @@ class TestSnippets < Test::Unit::TestCase
assert_nothing_raised {
assert_equal(
- "//testing/Mytype[componentname]/File[/tmp/classtest]",
+ "//Testing/Mytype[componentname]/File[/tmp/classtest]",
file.path)
}
end
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 44c78f2c3..0cc3ddef4 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -53,9 +53,7 @@ module PuppetTest::ParserTesting
def mknode(name = nil)
require 'puppet/node'
- name ||= "nodename"
- Puppet::Network::Handler.handler(:node)
- Puppet::Node.new(name)
+ Puppet::Node.new(name || "nodename")
end
def mkparser
@@ -64,9 +62,9 @@ module PuppetTest::ParserTesting
end
def mkscope(hash = {})
- hash[:parser] ||= mkparser
- compiler ||= mkcompiler(hash[:parser])
- compiler.topscope.source = (hash[:parser].find_hostclass("", "") || hash[:parser].newclass(""))
+ parser ||= mkparser
+ compiler ||= mkcompiler
+ compiler.topscope.source = (parser.find_hostclass("", "") || parser.newclass(""))
unless compiler.topscope.source
raise "Could not find source for scope"
@@ -108,7 +106,7 @@ module PuppetTest::ParserTesting
:line => __LINE__,
:title => title,
:type => type,
- :params => resourceinst(params)
+ :parameters => resourceinst(params)
)
}
end
@@ -126,7 +124,7 @@ module PuppetTest::ParserTesting
:line => __LINE__,
:object => resourceref(type, title),
:type => type,
- :params => resourceinst(params)
+ :parameters => resourceinst(params)
)
}
end
@@ -273,7 +271,7 @@ module PuppetTest::ParserTesting
:file => __FILE__,
:line => __LINE__,
:type => type,
- :params => past
+ :parameters => past
)
}
end
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index fb5c15f51..04ed0bf09 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -33,7 +33,7 @@ module PuppetTest::RailsTesting
# Now build a resource
resources = []
resources << mkresource(:type => type, :title => title, :exported => true,
- :params => params)
+ :parameters => params)
# Now collect our facts
facts = Facter.to_hash
diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb
index 95fe5bcb7..2e4db1d76 100644
--- a/test/lib/puppettest/resourcetesting.rb
+++ b/test/lib/puppettest/resourcetesting.rb
@@ -23,11 +23,11 @@ module PuppetTest::ResourceTesting
args[param] ||= value
end
- params = args[:params] || {:one => "yay", :three => "rah"}
- if args[:params] == :none
- args.delete(:params)
+ params = args[:parameters] || {:one => "yay", :three => "rah"}
+ if args[:parameters] == :none
+ args.delete(:parameters)
else
- args[:params] = paramify args[:source], params
+ args[:parameters] = paramify args[:source], params
end
Parser::Resource.new(type, title, args)
diff --git a/test/lib/puppettest/support/collection.rb b/test/lib/puppettest/support/collection.rb
deleted file mode 100644
index 9da15ea81..000000000
--- a/test/lib/puppettest/support/collection.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-
-module PuppetTest::Support::Collection
- def run_collection_queries(form)
- {true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
- %{title == "/tmp/testing" and group == bin}, %{title == bin or group == bin},
- %{title == "/tmp/testing" or title == bin}, %{title == "/tmp/testing"},
- %{(title == "/tmp/testing" or title == bin) and group == bin}],
- false => [%{title == bin}, %{title == bin or (title == bin and group == bin)},
- %{title != "/tmp/testing"}, %{title != "/tmp/testing" and group != bin}]
- }.each do |res, ary|
- ary.each do |str|
- if form == :virtual
- code = "File <| #{str} |>"
- else
- code = "File <<| #{str} |>>"
- end
- parser = mkparser
- query = nil
-
- assert_nothing_raised("Could not parse '#{str}'") do
- query = parser.parse(code).hostclass("").code[0].query
- end
-
- yield str, res, query
- end
- end
- end
-end
-