summaryrefslogtreecommitdiffstats
path: root/test/language
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-04 12:09:48 -0500
committerLuke Kanies <luke@madstop.com>2007-09-04 12:09:48 -0500
commit3b2efd2a4b32478b6c6a71e1421061405a0bb11e (patch)
tree72e5ada4b0eeb3c83a1f20dfb524363a3fc5db81 /test/language
parent0faf76ee187c7fa7c67a7fb7e7c345897006b7d8 (diff)
downloadpuppet-3b2efd2a4b32478b6c6a71e1421061405a0bb11e.tar.gz
puppet-3b2efd2a4b32478b6c6a71e1421061405a0bb11e.tar.xz
puppet-3b2efd2a4b32478b6c6a71e1421061405a0bb11e.zip
We now have a real configuration object, as a subclass of GRATR::Digraph, that has a resource graph including resources for the container objects like classes and nodes. It is apparently functional, but I have not gone through all of the other tests to fix them yet. That is next.
Diffstat (limited to 'test/language')
-rwxr-xr-xtest/language/ast/resourceref.rb2
-rwxr-xr-xtest/language/compile.rb101
-rwxr-xr-xtest/language/resource.rb17
-rwxr-xr-xtest/language/scope.rb14
-rwxr-xr-xtest/language/snippets.rb5
5 files changed, 16 insertions, 123 deletions
diff --git a/test/language/ast/resourceref.rb b/test/language/ast/resourceref.rb
index 1145e5125..dd7e7037f 100755
--- a/test/language/ast/resourceref.rb
+++ b/test/language/ast/resourceref.rb
@@ -91,5 +91,3 @@ class TestASTResourceRef < Test::Unit::TestCase
end
end
end
-
-# $Id$
diff --git a/test/language/compile.rb b/test/language/compile.rb
index 3128b8e64..a4adcd963 100755
--- a/test/language/compile.rb
+++ b/test/language/compile.rb
@@ -255,19 +255,6 @@ class TestCompile < Test::Unit::TestCase
end
end
- # Make sure our config object handles tags appropriately.
- def test_tags
- config = mkconfig
- config.send(:tag, "one")
- assert_equal(%w{one}, config.send(:tags), "Did not add tag")
-
- config.send(:tag, "two", "three")
- assert_equal(%w{one two three}, config.send(:tags), "Did not add new tags")
-
- config.send(:tag, "two")
- assert_equal(%w{one two three}, config.send(:tags), "Allowed duplicate tag")
- end
-
def test_evaluate_node_classes
config = mkconfig
@node.classes = %w{one two three four}
@@ -469,94 +456,6 @@ class TestCompile < Test::Unit::TestCase
config.send(:finish)
end
- def test_extract
- config = mkconfig
- config.expects(:extraction_format).returns(:whatever)
- config.expects(:extract_to_whatever).returns(:result)
- assert_equal(:result, config.send(:extract), "Did not return extraction result as the method result")
- end
-
- # We want to make sure that the scope and resource graphs translate correctly
- def test_extract_to_transportable_simple
- # Start with a really simple graph -- one scope, one resource.
- config = mkconfig
- resources = config.instance_variable_get("@resource_graph")
- scopes = config.instance_variable_get("@scope_graph")
-
- # Get rid of the topscope
- scopes.vertices.each { |v| scopes.remove_vertex!(v) }
-
- bucket = []
- scope = mock("scope")
- bucket.expects(:copy_type_and_name).with(scope)
- scope.expects(:to_trans).returns(bucket)
- scopes.add_vertex! scope
-
- # The topscope is the key to picking out the top of the graph.
- config.instance_variable_set("@topscope", scope)
-
- resource = mock "resource"
- resource.expects(:to_trans).returns(:resource)
- resources.add_edge! scope, resource
-
- result = nil
- assert_nothing_raised("Could not extract transportable compile") do
- result = config.send :extract_to_transportable
- end
- assert_equal([:resource], result, "Did not translate simple compile correctly")
- end
-
- def test_extract_to_transportable_complex
- # Now try it with a more complicated graph -- a three tier graph, each tier
- # having a scope and a resource.
- config = mkconfig
- resources = config.instance_variable_get("@resource_graph")
- scopes = config.instance_variable_get("@scope_graph")
-
- # Get rid of the topscope
- scopes.vertices.each { |v| scopes.remove_vertex!(v) }
-
- fakebucket = Class.new(Array) do
- attr_accessor :name
- def initialize(n)
- @name = n
- end
- end
-
- # Create our scopes.
- top = mock("top")
- topbucket = fakebucket.new "top"
- topbucket.expects(:copy_type_and_name).with(top)
- top.stubs(:copy_type_and_name)
- top.expects(:to_trans).returns(topbucket)
- # The topscope is the key to picking out the top of the graph.
- config.instance_variable_set("@topscope", top)
- middle = mock("middle")
- middle.expects(:to_trans).returns(fakebucket.new("middle"))
- scopes.add_edge! top, middle
- bottom = mock("bottom")
- bottom.expects(:to_trans).returns(fakebucket.new("bottom"))
- scopes.add_edge! middle, bottom
-
- topres = mock "topres"
- topres.expects(:to_trans).returns(:topres)
- resources.add_edge! top, topres
-
- midres = mock "midres"
- midres.expects(:to_trans).returns(:midres)
- resources.add_edge! middle, midres
-
- botres = mock "botres"
- botres.expects(:to_trans).returns(:botres)
- resources.add_edge! bottom, botres
-
- result = nil
- assert_nothing_raised("Could not extract transportable compile") do
- result = config.send :extract_to_transportable
- end
- assert_equal([[[:botres], :midres], :topres], result, "Did not translate medium compile correctly")
- end
-
def test_verify_uniqueness
config = mkconfig
diff --git a/test/language/resource.rb b/test/language/resource.rb
index 892d8c293..f594691c6 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -209,7 +209,7 @@ class TestResource < PuppetTest::TestCase
res.send(:paramcheck, :other)
end
- def test_to_trans
+ def test_to_transobject
# First try translating a builtin resource. Make sure we use some references
# and arrays, to make sure they translate correctly.
source = mock("source")
@@ -242,6 +242,21 @@ class TestResource < PuppetTest::TestCase
assert_equal(["file", refs[3].title], obj["notify"], "Array with single resource reference was not turned into single value")
end
+ # FIXME This isn't a great test, but I need to move on.
+ def test_to_transbucket
+ bucket = mock("transbucket")
+ Puppet::TransBucket.expects(:new).with([]).returns(bucket)
+ source = mock("source")
+ scope = mock("scope")
+ res = Parser::Resource.new :type => "mydefine", :title => "yay",
+ :source => source, :scope => scope
+
+ bucket.expects(:name=).with("yay")
+ bucket.expects(:type=).with("mydefine")
+
+ assert_equal(bucket, res.to_trans, "Resource did not return the bucket")
+ end
+
def test_evaluate
# First try the most common case, we're not a builtin type.
res = mkresource
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 43cbfd47c..66bc632bf 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -506,20 +506,6 @@ Host <<||>>"
assert_equal((ptags + %w{onemore subscope}).sort, newscope.tags.sort)
end
- # FIXME This isn't a great test, but I need to move on.
- def test_to_trans
- bucket = mock("transbucket")
- Puppet::TransBucket.expects(:new).with([]).returns(bucket)
- scope = mkscope
- scope.type = "mytype"
- scope.name = "myname"
-
- bucket.expects(:name=).with("myname")
- bucket.expects(:type=).with("mytype")
-
- scope.to_trans
- end
-
def test_namespaces
parser, scope, source = mkclassframing
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index c3c60e77f..2c74543e7 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -496,9 +496,6 @@ class TestSnippets < Test::Unit::TestCase
assert_nothing_raised {
client.getconfig()
}
- #assert_nothing_raised {
- # trans = client.apply()
- #}
Puppet::Type.eachtype { |type|
type.each { |obj|
@@ -520,5 +517,3 @@ class TestSnippets < Test::Unit::TestCase
end
}
end
-
-# $Id$