diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-20 05:14:13 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-20 05:14:13 +0000 |
| commit | e24a299511f6a23019edfee16e2541c8078d3f5d (patch) | |
| tree | 304cd64de34e628f922ba3695a67b65308562894 /test | |
| parent | ac049810032ed655b0ea32650127d38df39e1089 (diff) | |
A simple first version of an object (called "pelement") server is now in place. There is not yet a client, and the tests are pretty simple so far -- only files have been tested yet. I had to make a significant number of modifications to the file object in order to get this all to work, and one of the big changes I made is to the internals of the checksum state.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1123 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rw-r--r-- | test/server/pelement.rb | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/server/pelement.rb b/test/server/pelement.rb new file mode 100644 index 000000000..3e55918dd --- /dev/null +++ b/test/server/pelement.rb @@ -0,0 +1,81 @@ +if __FILE__ == $0 + $:.unshift '../../lib' + $:.unshift '..' + $puppetbase = "../.." +end + +require 'puppet' +require 'puppet/server/pelement' +require 'test/unit' +require 'puppettest.rb' +require 'base64' +require 'cgi' + +class TestPElementServer < Test::Unit::TestCase + include ServerTest + + def test_describe_file + # Make a file to describe + file = tempfile() + str = "yayness\n" + + server = nil + + assert_nothing_raised do + server = Puppet::Server::PElementServer.new() + end + + [ [nil], + [[:content, :mode], []], + [[], [:content]], + [[:content], [:mode]] + ].each do |ary| + retrieve = ary[0] || [] + ignore = ary[1] || [] + + File.open(file, "w") { |f| f.print str } + + result = nil + assert_nothing_raised do + result = server.describe("file", file, *ary) + end + + assert(result, "Could not retrieve file information") + + assert_instance_of(Puppet::TransObject, result) + + # Now we have to clear, so that the server's object gets removed + Puppet::Type.type(:file).clear + + # And remove the file, so we can verify it gets recreated + File.unlink(file) + + object = nil + assert_nothing_raised do + object = result.to_type + end + + assert(object, "Could not create type") + + retrieve.each do |state| + assert(object.should(state), "Did not retrieve %s" % state) + end + + ignore.each do |state| + assert(! object.should(state), "Incorrectly retrieved %s" % state) + end + + assert_events([:file_created], object) + + assert(FileTest.exists?(file), "File did not get recreated") + + if object.should(:content) + assert_equal(str, File.read(file), "File contents are not the same") + else + assert_equal("", File.read(file), "File content was incorrectly made") + end + end + end +end + +# $Id$ |
