summaryrefslogtreecommitdiff
path: root/t/test-parser.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-15 08:17:13 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-15 08:17:13 +0000
commit661ed3c406df3e87282814d177c851572776d712 (patch)
tree6689009b26dc65f6a0f8604d1ae84613cc22cb3a /t/test-parser.rb
parent1a45ecd112d692a176b7349c30fab0690905c754 (diff)
Throw an exception if we attempt to redefine a macro.
Diffstat (limited to 't/test-parser.rb')
-rwxr-xr-xt/test-parser.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/t/test-parser.rb b/t/test-parser.rb
index c3e782f..f405433 100755
--- a/t/test-parser.rb
+++ b/t/test-parser.rb
@@ -57,7 +57,6 @@ class TestParser < Test::Unit::TestCase
assert_nothing_raised do
MonitorConfig.new("/dev/null" )
end
-
end
@@ -171,6 +170,41 @@ class TestParser < Test::Unit::TestCase
+ #
+ # Redefinining a macro should cause an error
+ #
+ def test_duplicate_macro
+
+
+ #
+ # Create the parser.
+ #
+ parser = MonitorConfig.new("/dev/null" )
+
+
+ #
+ # With nothing loaded we should have zero macros - so the
+ # count of our macros hash should be zero
+ #
+ macros = parser.macros
+ assert( macros.empty? )
+ assert( macros.size() == 0 )
+
+
+ #
+ # Define a macro twice. The first will work, the second will fail
+ #
+ assert_nothing_raised do
+ parser.define_macro( "FOO is kvm1.vm.bytemark.co.uk and kvm2.vm.bytemark.co.uk." )
+ end
+
+ assert_raise ArgumentError do
+ parser.define_macro( "FOO is kvm1.vm.bytemark.co.uk and kvm2.vm.bytemark.co.uk." )
+ end
+ end
+
+
+
#
# Test that we can define macros with only a single host.