order_spec.rb 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. require 'spec_helper_acceptance'
  2. describe 'concat order' do
  3. basedir = default.tmpdir('concat')
  4. context '=> alpha' do
  5. pp = <<-EOS
  6. concat { '#{basedir}/foo':
  7. order => 'alpha'
  8. }
  9. concat::fragment { '1':
  10. target => '#{basedir}/foo',
  11. content => 'string1',
  12. }
  13. concat::fragment { '2':
  14. target => '#{basedir}/foo',
  15. content => 'string2',
  16. }
  17. concat::fragment { '10':
  18. target => '#{basedir}/foo',
  19. content => 'string10',
  20. }
  21. EOS
  22. it 'applies the manifest twice with no stderr' do
  23. apply_manifest(pp, :catch_failures => true)
  24. apply_manifest(pp, :catch_changes => true)
  25. end
  26. describe file("#{basedir}/foo") do
  27. it { should be_file }
  28. #XXX Solaris 10 doesn't support multi-line grep
  29. it("should contain string10\nstring1\nsring2", :unless => (fact('osfamily') == 'Solaris')) {
  30. should contain "string10\nstring1\nsring2"
  31. }
  32. end
  33. end
  34. context '=> numeric' do
  35. pp = <<-EOS
  36. concat { '#{basedir}/foo':
  37. order => 'numeric'
  38. }
  39. concat::fragment { '1':
  40. target => '#{basedir}/foo',
  41. content => 'string1',
  42. }
  43. concat::fragment { '2':
  44. target => '#{basedir}/foo',
  45. content => 'string2',
  46. }
  47. concat::fragment { '10':
  48. target => '#{basedir}/foo',
  49. content => 'string10',
  50. }
  51. EOS
  52. it 'applies the manifest twice with no stderr' do
  53. apply_manifest(pp, :catch_failures => true)
  54. apply_manifest(pp, :catch_changes => true)
  55. end
  56. describe file("#{basedir}/foo") do
  57. it { should be_file }
  58. #XXX Solaris 10 doesn't support multi-line grep
  59. it("should contain string1\nstring2\nsring10", :unless => (fact('osfamily') == 'Solaris')) {
  60. should contain "string1\nstring2\nsring10"
  61. }
  62. end
  63. end
  64. end # concat order
  65. describe 'concat::fragment order' do
  66. basedir = default.tmpdir('concat')
  67. context '=> reverse order' do
  68. pp = <<-EOS
  69. concat { '#{basedir}/foo': }
  70. concat::fragment { '1':
  71. target => '#{basedir}/foo',
  72. content => 'string1',
  73. order => '15',
  74. }
  75. concat::fragment { '2':
  76. target => '#{basedir}/foo',
  77. content => 'string2',
  78. # default order 10
  79. }
  80. concat::fragment { '3':
  81. target => '#{basedir}/foo',
  82. content => 'string3',
  83. order => '1',
  84. }
  85. EOS
  86. it 'applies the manifest twice with no stderr' do
  87. apply_manifest(pp, :catch_failures => true)
  88. apply_manifest(pp, :catch_changes => true)
  89. end
  90. describe file("#{basedir}/foo") do
  91. it { should be_file }
  92. #XXX Solaris 10 doesn't support multi-line grep
  93. it("should contain string3\nstring2\nsring1", :unless => (fact('osfamily') == 'Solaris')) {
  94. should contain "string3\nstring2\nsring1"
  95. }
  96. end
  97. end
  98. context '=> normal order' do
  99. pp = <<-EOS
  100. concat { '#{basedir}/foo': }
  101. concat::fragment { '1':
  102. target => '#{basedir}/foo',
  103. content => 'string1',
  104. order => '01',
  105. }
  106. concat::fragment { '2':
  107. target => '#{basedir}/foo',
  108. content => 'string2',
  109. order => '02'
  110. }
  111. concat::fragment { '3':
  112. target => '#{basedir}/foo',
  113. content => 'string3',
  114. order => '03',
  115. }
  116. EOS
  117. it 'applies the manifest twice with no stderr' do
  118. apply_manifest(pp, :catch_failures => true)
  119. apply_manifest(pp, :catch_changes => true)
  120. end
  121. describe file("#{basedir}/foo") do
  122. it { should be_file }
  123. #XXX Solaris 10 doesn't support multi-line grep
  124. it("should contain string1\nstring2\nsring3", :unless => (fact('osfamily') == 'Solaris')) {
  125. should contain "string1\nstring2\nsring3"
  126. }
  127. end
  128. end
  129. end # concat::fragment order