summaryrefslogtreecommitdiffstats
path: root/acceptance/tests/apply/classes
diff options
context:
space:
mode:
authorDominic Maraglia <dmaraglia@gmail.com>2011-04-20 14:58:26 -0700
committerDominic Maraglia <dmaraglia@gmail.com>2011-04-20 14:58:26 -0700
commitac428b9557e2da251e4b51e48de844833ca0aa2a (patch)
treeb3ccc5cf1a0dae6e2662dc61855281dc6ba8e8d5 /acceptance/tests/apply/classes
parent97e9e5f223cb7baefd52456e2324c592fe415dca (diff)
Move tests from Puppet-acceptance repo
Diffstat (limited to 'acceptance/tests/apply/classes')
-rwxr-xr-xacceptance/tests/apply/classes/parameterized_classes.rb56
-rwxr-xr-xacceptance/tests/apply/classes/should_allow_param_override.rb20
-rwxr-xr-xacceptance/tests/apply/classes/should_allow_param_undef_override.rb29
-rwxr-xr-xacceptance/tests/apply/classes/should_include_resources_from_class.rb11
-rwxr-xr-xacceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb6
5 files changed, 122 insertions, 0 deletions
diff --git a/acceptance/tests/apply/classes/parameterized_classes.rb b/acceptance/tests/apply/classes/parameterized_classes.rb
new file mode 100755
index 000000000..9a7029425
--- /dev/null
+++ b/acceptance/tests/apply/classes/parameterized_classes.rb
@@ -0,0 +1,56 @@
+test_name "parametrized classes"
+
+########################################################################
+step "should allow param classes"
+manifest = %q{
+class x($y, $z) {
+ notice("${y}-${z}")
+}
+class {x: y => '1', z => '2'}
+}
+
+apply_manifest_on(agents, manifest) do
+ fail_test "inclusion after parameterization failed" unless stdout.include? "1-2"
+end
+
+########################################################################
+# REVISIT: This was ported from the old set of tests, but I think that
+# the desired behaviour has recently changed. --daniel 2010-12-23
+step "should allow param class post inclusion"
+manifest = %q{
+class x($y, $z) {
+ notice("${y}-${z}")
+}
+class {x: y => '1', z => '2'}
+include x
+}
+
+apply_manifest_on(agents, manifest) do
+ fail_test "inclusion after parameterization failed" unless stdout.include? "1-2"
+end
+
+########################################################################
+step "should allow param classes defaults"
+manifest = %q{
+class x($y, $z='2') {
+ notice("${y}-${z}")
+}
+class {x: y => '1'}
+}
+
+apply_manifest_on(agents, manifest) do
+ fail_test "the default didn't apply as expected" unless stdout.include? "1-2"
+end
+
+########################################################################
+step "should allow param class defaults to be overriden"
+manifest = %q{
+class x($y, $z='2') {
+ notice("${y}-${z}")
+}
+class {x: y => '1', z => '3'}
+}
+
+apply_manifest_on(agents, manifest) do
+ fail_test "the override didn't happen as we expected" unless stdout.include? "1-3"
+end
diff --git a/acceptance/tests/apply/classes/should_allow_param_override.rb b/acceptance/tests/apply/classes/should_allow_param_override.rb
new file mode 100755
index 000000000..09592ec8b
--- /dev/null
+++ b/acceptance/tests/apply/classes/should_allow_param_override.rb
@@ -0,0 +1,20 @@
+test_name "should allow param override"
+
+manifest = %q{
+class parent {
+ notify { 'msg':
+ message => parent,
+ }
+}
+class child inherits parent {
+ Notify['msg'] {message => 'child'}
+}
+include parent
+include child
+}
+
+apply_manifest_on(agents, manifest) do
+ fail_test "parameter override didn't work" unless
+ stdout.include? "defined 'message' as 'child'"
+end
+
diff --git a/acceptance/tests/apply/classes/should_allow_param_undef_override.rb b/acceptance/tests/apply/classes/should_allow_param_undef_override.rb
new file mode 100755
index 000000000..a4f37cba1
--- /dev/null
+++ b/acceptance/tests/apply/classes/should_allow_param_undef_override.rb
@@ -0,0 +1,29 @@
+test_name "should allow overriding a parameter to undef in inheritence"
+
+out = "/tmp/class_undef_override_out-#{$$}"
+manifest = %Q{
+ class parent {
+ file { 'test':
+ path => '#{out}',
+ source => '/tmp/class_undef_override_test-#{$$}',
+ }
+ }
+ class child inherits parent {
+ File['test'] {
+ source => undef,
+ content => 'hello new world!',
+ }
+ }
+ include parent
+ include child
+}
+
+step "prepare the target file on all systems"
+on(agents, "echo 'hello world!' > #{out}")
+step "apply the manifest"
+apply_manifest_on(agents, manifest)
+step "verify the file content"
+on(agents, "cat #{out}") do
+ fail_test "the file was not touched" if stdout.include? "hello world!"
+ fail_test "the file was not updated" unless stdout.include? "hello new world"
+end
diff --git a/acceptance/tests/apply/classes/should_include_resources_from_class.rb b/acceptance/tests/apply/classes/should_include_resources_from_class.rb
new file mode 100755
index 000000000..b78be6cec
--- /dev/null
+++ b/acceptance/tests/apply/classes/should_include_resources_from_class.rb
@@ -0,0 +1,11 @@
+test_name "resources declared in a class can be applied with include"
+manifest = %q{
+class x {
+ notify{'a':}
+}
+include x
+}
+apply_manifest_on(agents, manifest) do
+ fail_test "the resource did not apply" unless
+ stdout.include? "defined 'message' as 'a'"
+end
diff --git a/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb b/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb
new file mode 100755
index 000000000..25721eb4c
--- /dev/null
+++ b/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb
@@ -0,0 +1,6 @@
+test_name "resources declared in classes are not applied without include"
+manifest = %q{ class x { notify { 'test': message => 'never invoked' } } }
+apply_manifest_on(agents, manifest) do
+ fail_test "found the notify despite not including it" if
+ stdout.include? "never invoked"
+end