From 41b7fbd3d5a3a69baff877fcba0edc677a30a05b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 18 Apr 2005 15:28:01 +0000 Subject: renaming oparse to filetype git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@172 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/objects/tc_filetype.rb | 115 ++++++++++++++++++++++++++++++++++++++++++++ test/other/tc_oparse.rb | 115 -------------------------------------------- 2 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 test/objects/tc_filetype.rb delete mode 100644 test/other/tc_oparse.rb diff --git a/test/objects/tc_filetype.rb b/test/objects/tc_filetype.rb new file mode 100644 index 000000000..b31a42955 --- /dev/null +++ b/test/objects/tc_filetype.rb @@ -0,0 +1,115 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end + +require 'blink' +require 'blink/types/filetype' +require 'test/unit' + +# $Id$ + +class TestFileType < Test::Unit::TestCase + def setup + Blink[:debug] = 1 + + @passwdtype = Blink::FileType["passwd"] + if @passwdtype.nil? + assert_nothing_raised() { + @passwdtype = Blink::FileType.newtype( + :name => "passwd", + :recordsplit => ":", + :fields => %w{name password uid gid gcos home shell}, + :namevar => "name" + ) + } + end + + @passwdtype = Blink::FileType["passwd"] + if @passwdtype.nil? + assert_nothing_raised() { + @passwdtype = Blink::FileType.newtype( + :name => "passwd", + :recordsplit => ":", + :fields => %w{name password uid gid gcos home shell}, + :namevar => "name" + ) + } + end + end + + def test_passwd1_nochange + file = nil + type = nil + assert_nothing_raised() { + file = @passwdtype.new("/etc/passwd") + } + assert_nothing_raised() { + file.retrieve + } + + assert(file.insync?) + + contents = "" + File.open("/etc/passwd") { |ofile| + ofile.each { |line| + contents += line + } + } + + assert_equal( + contents, + file.to_s + ) + + end + + def test_passwd2_change + file = nil + type = nil + Kernel.system("cp /etc/passwd /tmp/oparsepasswd") + assert_nothing_raised() { + file = @passwdtype.new("/tmp/oparsepasswd") + } + assert_nothing_raised() { + file.retrieve + } + + assert(file.insync?) + + assert_nothing_raised() { + file.add { |obj| + obj["name"] = "yaytest" + obj["password"] = "x" + obj["uid"] = "10000" + obj["gid"] = "10000" + obj["home"] = "/home/yaytest" + obj["gcos"] = "The Yaytest" + obj["shell"] = "/bin/sh" + } + } + + assert(!file.insync?) + + assert_nothing_raised() { + file.sync + } + + assert(file.insync?) + + assert_nothing_raised() { + file.delete("bin") + } + + assert(!file.insync?) + + assert_nothing_raised() { + file.sync + } + + assert(file.insync?) + + #Kernel.system("rm /tmp/oparsepasswd") + end +end diff --git a/test/other/tc_oparse.rb b/test/other/tc_oparse.rb deleted file mode 100644 index b31a42955..000000000 --- a/test/other/tc_oparse.rb +++ /dev/null @@ -1,115 +0,0 @@ -if __FILE__ == $0 - $:.unshift '..' - $:.unshift '../../lib' - $blinkbase = "../.." -end - -require 'blink' -require 'blink/types/filetype' -require 'test/unit' - -# $Id$ - -class TestFileType < Test::Unit::TestCase - def setup - Blink[:debug] = 1 - - @passwdtype = Blink::FileType["passwd"] - if @passwdtype.nil? - assert_nothing_raised() { - @passwdtype = Blink::FileType.newtype( - :name => "passwd", - :recordsplit => ":", - :fields => %w{name password uid gid gcos home shell}, - :namevar => "name" - ) - } - end - - @passwdtype = Blink::FileType["passwd"] - if @passwdtype.nil? - assert_nothing_raised() { - @passwdtype = Blink::FileType.newtype( - :name => "passwd", - :recordsplit => ":", - :fields => %w{name password uid gid gcos home shell}, - :namevar => "name" - ) - } - end - end - - def test_passwd1_nochange - file = nil - type = nil - assert_nothing_raised() { - file = @passwdtype.new("/etc/passwd") - } - assert_nothing_raised() { - file.retrieve - } - - assert(file.insync?) - - contents = "" - File.open("/etc/passwd") { |ofile| - ofile.each { |line| - contents += line - } - } - - assert_equal( - contents, - file.to_s - ) - - end - - def test_passwd2_change - file = nil - type = nil - Kernel.system("cp /etc/passwd /tmp/oparsepasswd") - assert_nothing_raised() { - file = @passwdtype.new("/tmp/oparsepasswd") - } - assert_nothing_raised() { - file.retrieve - } - - assert(file.insync?) - - assert_nothing_raised() { - file.add { |obj| - obj["name"] = "yaytest" - obj["password"] = "x" - obj["uid"] = "10000" - obj["gid"] = "10000" - obj["home"] = "/home/yaytest" - obj["gcos"] = "The Yaytest" - obj["shell"] = "/bin/sh" - } - } - - assert(!file.insync?) - - assert_nothing_raised() { - file.sync - } - - assert(file.insync?) - - assert_nothing_raised() { - file.delete("bin") - } - - assert(!file.insync?) - - assert_nothing_raised() { - file.sync - } - - assert(file.insync?) - - #Kernel.system("rm /tmp/oparsepasswd") - end -end -- cgit