summaryrefslogtreecommitdiffstats
path: root/test/objects
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-18 15:28:01 +0000
committerLuke Kanies <luke@madstop.com>2005-04-18 15:28:01 +0000
commit41b7fbd3d5a3a69baff877fcba0edc677a30a05b (patch)
tree30e8501e38f9b19c6a342e8f45bdc1aaedfbd17d /test/objects
parent98374bc979a6135d2becad0a3da581d411b72502 (diff)
downloadpuppet-41b7fbd3d5a3a69baff877fcba0edc677a30a05b.tar.gz
puppet-41b7fbd3d5a3a69baff877fcba0edc677a30a05b.tar.xz
puppet-41b7fbd3d5a3a69baff877fcba0edc677a30a05b.zip
renaming oparse to filetype
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@172 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/objects')
-rw-r--r--test/objects/tc_filetype.rb115
1 files changed, 115 insertions, 0 deletions
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