summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/compile.rb14
-rwxr-xr-xtest/language/snippets.rb45
-rwxr-xr-xtest/rails/configuration.rb1
3 files changed, 18 insertions, 42 deletions
diff --git a/test/language/compile.rb b/test/language/compile.rb
index 5732acba3..7a8a613af 100755
--- a/test/language/compile.rb
+++ b/test/language/compile.rb
@@ -23,7 +23,7 @@ class TestCompile < Test::Unit::TestCase
def mkparser
# This should mock an interpreter
- @parser = stub 'parser', :version => "1.0"
+ @parser = stub 'parser', :version => "1.0", :nodes => {}
end
def mkcompile(options = {})
@@ -38,7 +38,7 @@ class TestCompile < Test::Unit::TestCase
def test_initialize
compile = nil
node = stub 'node', :name => "foo"
- parser = stub 'parser', :version => "1.0"
+ parser = stub 'parser', :version => "1.0", :nodes => {}
assert_nothing_raised("Could not init compile with all required options") do
compile = Compile.new(node, parser)
end
@@ -51,7 +51,7 @@ class TestCompile < Test::Unit::TestCase
# Now try it with some options
assert_nothing_raised("Could not init compile with extra options") do
- compile = Compile.new(node, parser, :ast_nodes => false)
+ compile = Compile.new(node, parser)
end
assert_equal(false, compile.ast_nodes?, "Did not set ast_nodes? correctly")
@@ -188,7 +188,7 @@ class TestCompile < Test::Unit::TestCase
# Make sure we either don't look for nodes, or that we find and evaluate the right object.
def test_evaluate_ast_node
# First try it with ast_nodes disabled
- compile = mkcompile :ast_nodes => false
+ compile = mkcompile
name = compile.node.name
compile.expects(:ast_nodes?).returns(false)
compile.parser.expects(:nodes).never
@@ -201,7 +201,7 @@ class TestCompile < Test::Unit::TestCase
# Now try it with them enabled, but no node found.
nodes = mock 'node_hash'
- compile = mkcompile :ast_nodes => true
+ compile = mkcompile
name = compile.node.name
compile.expects(:ast_nodes?).returns(true)
compile.parser.stubs(:nodes).returns(nodes)
@@ -221,7 +221,7 @@ class TestCompile < Test::Unit::TestCase
end
# Finally, make sure it works dandily when we have a node
- compile = mkcompile :ast_nodes => true
+ compile = mkcompile
compile.expects(:ast_nodes?).returns(true)
node = stub 'node', :classname => "c"
@@ -240,7 +240,7 @@ class TestCompile < Test::Unit::TestCase
"Did not create node resource")
# Lastly, check when we actually find the default.
- compile = mkcompile :ast_nodes => true
+ compile = mkcompile
compile.expects(:ast_nodes?).returns(true)
node = stub 'node', :classname => "default"
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 7168a81d8..cc3859552 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -449,45 +449,24 @@ class TestSnippets < Test::Unit::TestCase
#eval("alias %s %s" % [testname, mname])
testname = ("test_" + mname).intern
self.send(:define_method, testname) {
+ Puppet[:manifest] = snippet(file)
facts = {
"hostname" => "testhost",
"domain" => "domain.com",
"ipaddress" => "127.0.0.1",
"fqdn" => "testhost.domain.com"
}
- Facter.stubs(:each)
- facts.each do |name, value|
- Facter.stubs(:value).with(name).returns(value)
- end
- # first parse the file
- server = Puppet::Network::Handler.master.new(
- :Manifest => snippet(file),
- :Local => true
- )
- facts = Puppet::Node::Facts.new("testhost", facts)
- Puppet::Node::Facts.stubs(:save)
- Puppet::Node::Facts.stubs(:find).returns(facts)
- client = Puppet::Network::Client.master.new(
- :Master => server,
- :Cache => false
- )
- client.class.stubs(:facts).returns(facts.values)
-
- assert(client.local)
- assert_nothing_raised {
- client.getconfig()
- }
- client = Puppet::Network::Client.master.new(
- :Master => server,
- :Cache => false
- )
+ node = Puppet::Node.new("testhost")
+ node.merge(facts)
- assert(client.local)
- # Now do it again
- Puppet::Type.allclear
- assert_nothing_raised {
- client.getconfig()
+ config = nil
+ assert_nothing_raised("Could not compile configuration") {
+ config = Puppet::Node::Configuration.find(node)
+ }
+
+ assert_nothing_raised("Could not convert configuration") {
+ config = config.extract_to_transportable.to_configuration
}
Puppet::Type.eachtype { |type|
@@ -500,12 +479,10 @@ class TestSnippets < Test::Unit::TestCase
assert(obj.name)
}
}
- @configuration = client.configuration
+ @configuration = config
assert_nothing_raised {
self.send(mname)
}
-
- client.clear
}
mname = mname.intern
end
diff --git a/test/rails/configuration.rb b/test/rails/configuration.rb
index 752ea5375..07665d576 100755
--- a/test/rails/configuration.rb
+++ b/test/rails/configuration.rb
@@ -25,7 +25,6 @@ class ConfigurationRailsTests < PuppetTest::TestCase
def test_finish_before_store
railsinit
compile = mkcompile
- compile.ast_nodes = true
parser = compile.parser
node = parser.newnode [compile.node.name], :code => AST::ASTArray.new(:children => [