concat_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require 'spec_helper_acceptance'
  2. describe 'concat function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $output = concat(['1','2','3'],['4','5','6'])
  6. validate_array($output)
  7. if size($output) != 6 {
  8. fail("${output} should have 6 elements.")
  9. }
  10. DOC
  11. it 'concats one array to another' do
  12. apply_manifest(pp1, :catch_failures => true)
  13. end
  14. pp2 = <<-DOC
  15. $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
  16. validate_array($output)
  17. if size($output) != 9 {
  18. fail("${output} should have 9 elements.")
  19. }
  20. DOC
  21. it 'concats arrays and primitives to array' do
  22. apply_manifest(pp2, :catch_failures => true)
  23. end
  24. pp3 = <<-DOC
  25. $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
  26. validate_array($output)
  27. if size($output) != 9 {
  28. fail("${output} should have 9 elements.")
  29. }
  30. DOC
  31. it 'concats multiple arrays to one' do
  32. apply_manifest(pp3, :catch_failures => true)
  33. end
  34. pp4 = <<-DOC
  35. $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
  36. validate_array($output)
  37. if size($output) != 2 {
  38. fail("${output} should have 2 elements.")
  39. }
  40. if $output[1] != {"c" => "d", "e" => "f"} {
  41. fail("${output} does not have the expected hash for the second element.")
  42. }
  43. DOC
  44. it 'concats hash arguments' do
  45. apply_manifest(pp4, :catch_failures => true)
  46. end
  47. end
  48. end