diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 20:01:12 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 20:01:12 +0000 |
| commit | 637cc71296f96fd1d5f2ca83aa7e20c73757f8dd (patch) | |
| tree | f3b055bf75d7df6cbabafb24334710071f2ef8ec /test/language/ast.rb | |
| parent | 9e9ef1acc6231254e52b96257ed1e81475d2d1bc (diff) | |
| download | puppet-637cc71296f96fd1d5f2ca83aa7e20c73757f8dd.tar.gz puppet-637cc71296f96fd1d5f2ca83aa7e20c73757f8dd.tar.xz puppet-637cc71296f96fd1d5f2ca83aa7e20c73757f8dd.zip | |
I appear to have object collection working, incredibly. This commit does the collection from the database up to adding the objects to the current scope, which is what sends it to the client.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1190 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/language/ast.rb')
| -rwxr-xr-x | test/language/ast.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb index b714fcdea..cb95fdff4 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -753,6 +753,62 @@ class TestAST < Test::Unit::TestCase end end + # Verify that our collection stuff works. + def test_collection + collectable = [] + non = [] + # First put some objects into the database. + bucket = mk_transtree do |object, depth, width| + # and mark some of them collectable + if width % 2 == 1 + object.collectable = true + collectable << object + else + non << object + end + end + + # Now collect our facts + facts = {} + Facter.each do |fact, value| facts[fact] = value end + + assert_nothing_raised { + Puppet::Rails.init + } + + # Now try storing our crap + assert_nothing_raised { + host = Puppet::Rails::Host.store( + :objects => bucket, + :facts => facts, + :host => facts["hostname"] + ) + } + + # Now create an ast tree that collects that. They should all be files. + coll = nil + assert_nothing_raised { + coll = AST::Collection.new( + :type => nameobj("file") + ) + } + + top = nil + assert_nothing_raised("Could not create top object") { + top = AST::ASTArray.new( + :children => [coll] + ) + } + + objects = nil + assert_nothing_raised("Could not evaluate") { + scope = Puppet::Parser::Scope.new() + objects = scope.evaluate(:ast => top).flatten + } + + assert(objects.length > 0, "Did not receive any collected objects") + end + # To fix #140. Currently non-functional. def disabled_test_classreuse children = [] |
