summaryrefslogtreecommitdiffstats
path: root/test/util
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-12 04:12:48 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-12 04:12:48 +0000
commitbd169b44a0ce58413fb5b031c3f12cd4ca6f4cbe (patch)
tree0411a38b49c5a311819c878c475672376c0f2578 /test/util
parent138150d1f240d3c249b2985540af1a7e327802e1 (diff)
Mounts work again, at least with the parsedfile provider. I still need to create a netinfo provider, but it should be short and easy. And, painfully, I still need to port the other six or so subclasses to this new provider.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1859 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/util')
-rwxr-xr-xtest/util/fileparsing.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb
index f5cf0d255..cebc3051e 100755
--- a/test/util/fileparsing.rb
+++ b/test/util/fileparsing.rb
@@ -273,6 +273,51 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
end
+ # Make sure fields that are marked absent get replaced with the appropriate
+ # string.
+ def test_absent_fields
+ parser = FParser.new
+
+ options = nil
+ assert_nothing_raised do
+ options = parser.record_line :record, :fields => %w{one two three}
+ end
+ assert_equal("", options[:absent], "Did not set a default absent string")
+
+ result = nil
+ assert_nothing_raised do
+ result = parser.to_line(:record_type => :record,
+ :one => "a", :two => :absent, :three => "b")
+ end
+
+ assert_equal("a b", result, "Absent was not correctly replaced")
+
+ # Now try using a different replacement character
+ options[:absent] = "*" # Because cron is a pain in my ass
+ assert_nothing_raised do
+ result = parser.to_line(:record_type => :record,
+ :one => "a", :two => :absent, :three => "b")
+ end
+
+ assert_equal("a * b", result, "Absent was not correctly replaced")
+
+ # Make sure we deal correctly with the string 'absent'
+ assert_nothing_raised do
+ result = parser.to_line(:record_type => :record,
+ :one => "a", :two => "b", :three => 'absent')
+ end
+
+ assert_equal("a b absent", result, "Replaced string 'absent'")
+
+ # And, of course, make sure we can swap things around.
+ assert_nothing_raised do
+ result = parser.to_line(:record_type => :record,
+ :one => "a", :two => "b", :three => :absent)
+ end
+
+ assert_equal("a b *", result, "Absent was not correctly replaced")
+ end
+
# Make sure we can specify a different join character than split character
def test_split_join_record_line
parser = FParser.new
@@ -331,6 +376,21 @@ billy three four"
end
end
+ def test_valid_attrs
+ parser = FParser.new
+
+ parser.record_line :record, :fields => %w{one two three}
+
+ assert(parser.valid_attr?(:record, :one),
+ "one was considered invalid")
+
+ assert(parser.valid_attr?(:record, :ensure),
+ "ensure was considered invalid")
+
+ assert(! parser.valid_attr?(:record, :four),
+ "four was considered valid")
+ end
+
# Make sure we correctly handle optional fields. We'll skip this
# functionality until we really know we need it.
def disabled_test_optional_fields