|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative 'integration_helper' |
| 4 | + |
| 5 | +OctocatalogDiff::Spec.require_path('/catalog') |
| 6 | + |
| 7 | +describe 'passes command line options to puppet' do |
| 8 | + context 'with one argument passed' do |
| 9 | + before(:all) do |
| 10 | + @result = OctocatalogDiff::Integration.integration( |
| 11 | + spec_repo_new: 'arbitrary-command-line', |
| 12 | + spec_fact_file: 'facts.yaml', |
| 13 | + argv: [ |
| 14 | + '-n', 'rspec-node.github.net', '--no-parallel', '--preserve-environments', |
| 15 | + '--from-catalog', OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'), |
| 16 | + '--command-line', '--environment=foo' |
| 17 | + ] |
| 18 | + ) |
| 19 | + end |
| 20 | + |
| 21 | + it 'should compile without exceptions' do |
| 22 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 23 | + expect(@result.exception).to be_nil |
| 24 | + end |
| 25 | + |
| 26 | + it 'should contain resource from environments/foo site.pp' do |
| 27 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 28 | + @result.diffs, |
| 29 | + ['+', "File\f/tmp/environment-foo-site"] |
| 30 | + )).to eq(true) |
| 31 | + end |
| 32 | + |
| 33 | + it 'should contain resource from environments/foo modules/foo' do |
| 34 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 35 | + @result.diffs, |
| 36 | + ['+', "File\f/tmp/environment-foo-module"] |
| 37 | + )).to eq(true) |
| 38 | + end |
| 39 | + |
| 40 | + it 'should not contain resource from environments/production' do |
| 41 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 42 | + @result.diffs, |
| 43 | + ['+', "File\f/tmp/environment-production-site"] |
| 44 | + )).to eq(false) |
| 45 | + end |
| 46 | + |
| 47 | + it 'should not contain resource from main modules/foo' do |
| 48 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 49 | + @result.diffs, |
| 50 | + ['+', "File\f/tmp/foo-module"] |
| 51 | + )).to eq(false) |
| 52 | + end |
| 53 | + end |
| 54 | + |
| 55 | + context 'with argument passed only to one catalog' do |
| 56 | + before(:all) do |
| 57 | + @result = OctocatalogDiff::Integration.integration( |
| 58 | + spec_repo_new: 'arbitrary-command-line', |
| 59 | + spec_fact_file: 'facts.yaml', |
| 60 | + argv: [ |
| 61 | + '-n', 'rspec-node.github.net', '--no-parallel', '--preserve-environments', |
| 62 | + '-f', '.', |
| 63 | + '--to-command-line', '--environment=foo' |
| 64 | + ] |
| 65 | + ) |
| 66 | + end |
| 67 | + |
| 68 | + it 'should compile without exceptions' do |
| 69 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 70 | + expect(@result.exception).to be_nil |
| 71 | + end |
| 72 | + |
| 73 | + it 'should contain resource from environments/foo site.pp only in to catalog' do |
| 74 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 75 | + @result.diffs, |
| 76 | + ['+', "File\f/tmp/environment-foo-site"] |
| 77 | + )).to eq(true) |
| 78 | + end |
| 79 | + |
| 80 | + it 'should contain resource from environments/foo modules/foo only in to catalog' do |
| 81 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 82 | + @result.diffs, |
| 83 | + ['+', "File\f/tmp/environment-foo-module"] |
| 84 | + )).to eq(true) |
| 85 | + end |
| 86 | + |
| 87 | + it 'should contain resource from environments/production only in from catalog' do |
| 88 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 89 | + @result.diffs, |
| 90 | + ['-', "File\f/tmp/environment-production-site"] |
| 91 | + )).to eq(true) |
| 92 | + end |
| 93 | + end |
| 94 | + |
| 95 | + context 'with override of an argument' do |
| 96 | + before(:all) do |
| 97 | + @result = OctocatalogDiff::Integration.integration( |
| 98 | + spec_repo_new: 'arbitrary-command-line', |
| 99 | + spec_fact_file: 'facts.yaml', |
| 100 | + argv: [ |
| 101 | + '-n', 'rspec-node.github.net', '--no-parallel', '--preserve-environments', |
| 102 | + '--from-catalog', OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'), |
| 103 | + '--command-line', '--environment=foo', |
| 104 | + '--environment', 'production' |
| 105 | + ] |
| 106 | + ) |
| 107 | + end |
| 108 | + |
| 109 | + it 'should compile without exceptions' do |
| 110 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 111 | + expect(@result.exception).to be_nil |
| 112 | + end |
| 113 | + |
| 114 | + it 'should contain resource from environments/foo site.pp' do |
| 115 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 116 | + @result.diffs, |
| 117 | + ['+', "File\f/tmp/environment-foo-site"] |
| 118 | + )).to eq(true) |
| 119 | + end |
| 120 | + |
| 121 | + it 'should contain resource from environments/foo modules/foo' do |
| 122 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 123 | + @result.diffs, |
| 124 | + ['+', "File\f/tmp/environment-foo-module"] |
| 125 | + )).to eq(true) |
| 126 | + end |
| 127 | + |
| 128 | + it 'should not contain resource from environments/production' do |
| 129 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 130 | + @result.diffs, |
| 131 | + ['+', "File\f/tmp/environment-production-site"] |
| 132 | + )).to eq(false) |
| 133 | + end |
| 134 | + |
| 135 | + it 'should not contain resource from main modules/foo' do |
| 136 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 137 | + @result.diffs, |
| 138 | + ['+', "File\f/tmp/foo-module"] |
| 139 | + )).to eq(false) |
| 140 | + end |
| 141 | + end |
| 142 | + |
| 143 | + context 'with multiple arguments' do |
| 144 | + before(:all) do |
| 145 | + @result = OctocatalogDiff::Integration.integration( |
| 146 | + spec_repo_new: 'arbitrary-command-line', |
| 147 | + spec_fact_file: 'facts.yaml', |
| 148 | + argv: [ |
| 149 | + '-n', 'rspec-node.github.net', '--no-parallel', '--preserve-environments', |
| 150 | + '--from-catalog', OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'), |
| 151 | + '--command-line', '--environment=foo', |
| 152 | + '--command-line', '--modulepath=modules' |
| 153 | + ] |
| 154 | + ) |
| 155 | + end |
| 156 | + |
| 157 | + it 'should compile without exceptions' do |
| 158 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 159 | + expect(@result.exception).to be_nil |
| 160 | + end |
| 161 | + |
| 162 | + it 'should contain resource from environments/foo site.pp' do |
| 163 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 164 | + @result.diffs, |
| 165 | + ['+', "File\f/tmp/environment-foo-site"] |
| 166 | + )).to eq(true) |
| 167 | + end |
| 168 | + |
| 169 | + it 'should not contain resource from environments/foo modules/foo' do |
| 170 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 171 | + @result.diffs, |
| 172 | + ['+', "File\f/tmp/environment-foo-module"] |
| 173 | + )).to eq(false) |
| 174 | + end |
| 175 | + |
| 176 | + it 'should not contain resource from environments/production' do |
| 177 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 178 | + @result.diffs, |
| 179 | + ['+', "File\f/tmp/environment-production-site"] |
| 180 | + )).to eq(false) |
| 181 | + end |
| 182 | + |
| 183 | + it 'should contain resource from main modules/foo' do |
| 184 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?( |
| 185 | + @result.diffs, |
| 186 | + ['+', "File\f/tmp/foo-module"] |
| 187 | + )).to eq(true) |
| 188 | + end |
| 189 | + end |
| 190 | +end |
0 commit comments