Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more tests for classes/conditionals/virtual resources.

  • Loading branch information...
commit ab6904416d5054cfe6ffb415bee05ddac18861ab 1 parent 56968c5
Dan Bode authored
Showing with 223 additions and 10 deletions.
  1. +1 −0  get_last.sh
  2. +0 −2  local_setup.example.sh
  3. +1 −0  run_last.sh
  4. 0  spec/apply/classes/should_allow_param_class_default_override_spec.sh
  5. 0  spec/apply/classes/should_allow_param_class_defaults_spec.sh
  6. 0  spec/apply/classes/should_allow_param_class_post_inclusion_spec.sh
  7. 0  spec/apply/classes/should_allow_param_classes_spec.sh
  8. +19 −0 spec/apply/classes/should_allow_param_override_spec.sh
  9. +24 −0 spec/apply/classes/should_allow_param_undef_override.sh
  10. 0  spec/apply/classes/should_include_resources_from_class_spec.sh
  11. 0  spec/apply/classes/should_not_auto_include_resources_from_class_spec.sh
  12. +6 −2 spec/apply/conditionals/should_evaluate_else_spec.sh
  13. +4 −3 spec/apply/conditionals/should_evaluate_elsif_spec.sh
  14. +13 −0 spec/apply/conditionals/should_evaluate_empty_spec.sh
  15. +13 −0 spec/apply/conditionals/should_evaluate_false_spec.sh
  16. +4 −3 spec/apply/conditionals/should_evaluate_if_spec.sh
  17. +14 −0 spec/apply/conditionals/should_evaluate_strings_true_spec.sh
  18. +9 −0 spec/apply/conditionals/should_evaluate_undef_spec.sh
  19. +33 −0 spec/apply/virtual/should_realize_complex_query_spec.sh
  20. +24 −0 spec/apply/virtual/should_realize_many_spec.sh
  21. +21 −0 spec/apply/virtual/should_realize_query_array_spec.sh
  22. +21 −0 spec/apply/virtual/should_realize_query_spec.sh
  23. +16 −0 spec/apply/virtual/should_realize_spec.sh
View
1  get_last.sh
@@ -0,0 +1 @@
+find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1
View
2  local_setup.example.sh
@@ -1,2 +0,0 @@
-cd ~/puppet/lib
-BIN=../bin
View
1  run_last.sh
@@ -0,0 +1 @@
+find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1 | bash
View
0  spec/apply/classes/should_allow_param_class_default_override_spec.sh 100644 → 100755
File mode changed
View
0  spec/apply/classes/should_allow_param_class_defaults_spec.sh 100644 → 100755
File mode changed
View
0  spec/apply/classes/should_allow_param_class_post_inclusion_spec.sh 100644 → 100755
File mode changed
View
0  spec/apply/classes/should_allow_param_classes_spec.sh 100644 → 100755
File mode changed
View
19 spec/apply/classes/should_allow_param_override_spec.sh
@@ -0,0 +1,19 @@
+set -e
+#
+# we are testing that resources declared in a class
+# can be applied with an include statement
+. local_setup.sh
+OUTFILE=/tmp/class_param_use-$$
+$BIN/puppet apply <<PP | tee $OUTFILE
+class parent {
+ notify { 'msg':
+ message => parent,
+ }
+}
+class child inherits parent {
+ Notify['msg'] {message => 'child'}
+}
+include parent
+include child
+PP
+grep "defined 'message' as 'child'" $OUTFILE
View
24 spec/apply/classes/should_allow_param_undef_override.sh
@@ -0,0 +1,24 @@
+set -e
+#
+# we are testing that resources declared in a class
+# can be applied with an include statement
+. local_setup.sh
+OUTFILE=/tmp/class_undef_override_out-$$
+echo 'hello world!' > /tmp/class_undef_override_test-$$
+$BIN/puppet apply <<PP | tee $OUTFILE
+class parent {
+ file { 'test':
+ path => '/tmp/class_undef_file-$$',
+ source => '/tmp/class_undef_override_test-$$',
+ }
+}
+class child inherits parent {
+ File['test'] {
+ source => undef,
+ content => 'hello new world!',
+ }
+}
+include parent
+include child
+PP
+grep "hello new world" /tmp/class_undef_file-$$
View
0  spec/apply/classes/should_include_resources_from_class_spec.sh 100644 → 100755
File mode changed
View
0  spec/apply/classes/should_not_auto_include_resources_from_class_spec.sh 100644 → 100755
File mode changed
View
8 spec/apply/conditionals/should_evaluate_else_spec.sh
@@ -1,8 +1,11 @@
set -e
-
+#
+# test that else clause will be reached
+# if no expressions match
+#
. local_setup.sh
-$BIN/puppet apply <<PP | grep notice | grep else
+$BIN/puppet apply <<PP | tee $OUTFILE
if( 1 == 2) {
notice('if')
} elsif(2 == 3) {
@@ -11,3 +14,4 @@ if( 1 == 2) {
notice('else')
}
PP
+grep 'else' $OUTFILE
View
7 spec/apply/conditionals/should_evaluate_elsif_spec.sh
@@ -1,8 +1,8 @@
-set -e
+#!/bin/bash
-. local_setup.sh
+source local_setup.sh
-$BIN/puppet apply <<PP | grep notice | grep elsif
+$BIN/puppet apply <<PP | tee $OUTFILE
if( 1 == 3) {
notice('if')
} elsif(2 == 2) {
@@ -11,3 +11,4 @@ if( 1 == 3) {
notice('else')
}
PP
+grep 'elsif' $OUTFILE
View
13 spec/apply/conditionals/should_evaluate_empty_spec.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# ensure that undefined variables evaluate as false
+#
+. local_setup.sh
+
+$BIN/puppet apply <<PP | tee $OUTFILE
+if \$undef_var {
+} else {
+ notice('undef')
+}
+PP
+grep 'undef' $OUTFILE
View
13 spec/apply/conditionals/should_evaluate_false_spec.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# test that false evaluates to false
+#
+source local_setup.sh
+
+$BIN/puppet <<PP | tee $OUTFILE
+if false {
+} else {
+ notice('false')
+}
+PP
+grep 'false' $OUTFILE
View
7 spec/apply/conditionals/should_evaluate_if_spec.sh
@@ -1,8 +1,8 @@
-set -e
+#!/bin/bash
-. local_setup.sh
+source local_setup.sh
-$BIN/puppet apply <<PP | grep notice | grep if
+$BIN/puppet apply <<PP | tee $OUTFILE
if( 1 == 1) {
notice('if')
} elsif(2 == 2) {
@@ -11,3 +11,4 @@ if( 1 == 1) {
notice('else')
}
PP
+grep 'if' $OUTFILE
View
14 spec/apply/conditionals/should_evaluate_strings_true_spec.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+#
+# test that the string 'false' evaluates to true
+#
+source local_setup.sh
+
+$BIN/puppet <<PP | tee $OUTFILE
+if 'false' {
+ notice('true')
+} else {
+ notice('false')
+}
+PP
+grep 'true' $OUTFILE
View
9 spec/apply/conditionals/should_evaluate_undef_spec.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+source local_setup.sh
+$BIN/puppet apply <<PP | tee $OUTFILE
+if '' {
+} else {
+ notice('empty')
+}
+PP
+grep empty $OUTFILE
View
33 spec/apply/virtual/should_realize_complex_query_spec.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+#
+#
+#
+set -e
+set -u
+
+. local_setup.sh
+
+HOSTFILE=/tmp/hosts-$$
+# precondition:
+# /tmp/hosts-$$ should not exist
+if [ -e $HOSTFILE ]; then
+ rm $HOSTFILE
+fi
+
+$BIN/puppet apply <<PP
+@host { 'test$$1':
+ ip=>'127.0.0.2',
+ target=>'$HOSTFILE',
+ host_aliases => ['one', 'two', 'three'],
+ ensure=>present,
+}
+@host { 'test$$2':
+ ip=>'127.0.0.3',
+ target=>'$HOSTFILE',
+ host_aliases => 'two',
+ ensure=>present,
+}
+Host<| host_aliases=='two' and ip=='127.0.0.3' |>
+PP
+grep test$$2 $HOSTFILE
View
24 spec/apply/virtual/should_realize_many_spec.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# test that realize function takes a list.
+#
+set -e
+set -u
+
+. local_setup.sh
+
+HOSTFILE=/tmp/hosts-$$
+# precondition:
+# /tmp/hosts-$$ should not exist
+if [ -e $HOSTFILE ]; then
+ rm $HOSTFILE
+fi
+
+# puppet code
+$BIN/puppet apply <<PP
+@host{'test$$1': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present}
+@host{'test$$2': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present}
+realize(Host['test$$1'], Host['test$$2'])
+PP
+# validate - validate that our hostifle contains more than one line that matches test$$
+[ $(grep test$$ $HOSTFILE | wc -l) == 2 ]
View
21 spec/apply/virtual/should_realize_query_array_spec.sh
@@ -0,0 +1,21 @@
+set -e
+
+. local_setup.sh
+
+HOSTFILE=/tmp/hosts-$$
+# precondition:
+# /tmp/hosts-$$ should not exist
+if [ -e $HOSTFILE ]; then
+ rm $HOSTFILE
+fi
+
+$BIN/puppet apply <<PP
+@host { 'test$$':
+ ip=>'127.0.0.2',
+ target=>'$HOSTFILE',
+ host_aliases => ['one', 'two', 'three'],
+ ensure=>present,
+}
+Host<| host_aliases=='two' |>
+PP
+grep test$$ $HOSTFILE
View
21 spec/apply/virtual/should_realize_query_spec.sh
@@ -0,0 +1,21 @@
+set -e
+
+. local_setup.sh
+
+HOSTFILE=/tmp/hosts-$$
+# precondition:
+# /tmp/hosts-$$ should not exist
+if [ -e $HOSTFILE ]; then
+ rm $HOSTFILE
+fi
+
+$BIN/puppet apply <<PP
+@host { 'test$$':
+ ip=>'127.0.0.2',
+ target=>'$HOSTFILE',
+ host_aliases => 'alias',
+ ensure=>present,
+}
+Host<| ip=='127.0.0.2' |>
+PP
+grep test$$ $HOSTFILE
View
16 spec/apply/virtual/should_realize_spec.sh
@@ -0,0 +1,16 @@
+set -e
+
+. local_setup.sh
+
+HOSTFILE=/tmp/hosts-$$
+# precondition:
+# /tmp/hosts-$$ should not exist
+if [ -e $HOSTFILE ]; then
+ rm $HOSTFILE
+fi
+
+$BIN/puppet apply <<PP
+@host{'test$$': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present}
+realize(Host['test$$'])
+PP
+grep test$$ $HOSTFILE
Please sign in to comment.
Something went wrong with that request. Please try again.