|
115 | 115 | end
|
116 | 116 | end
|
117 | 117 |
|
| 118 | + context 'when diff action is called' do |
| 119 | + let(:facter3_facts) { <<~END } |
| 120 | + { |
| 121 | + "macaddress": "64:52:11:22:03:2e", |
| 122 | + "filesystems": "apfs,autofs" |
| 123 | + } |
| 124 | + END |
| 125 | + |
| 126 | + let(:facter4_facts) { <<~END } |
| 127 | + { |
| 128 | + "macaddress": "64:52:11:22:03:2e", |
| 129 | + "filesystems": "apfs,autofs,devfs" |
| 130 | + } |
| 131 | + END |
| 132 | + |
| 133 | + before :each do |
| 134 | + Puppet::Node::Facts.indirection.terminus_class = :facter |
| 135 | + app.command_line.args = %w{diff} |
| 136 | + |
| 137 | + allow(Facter).to receive(:value).with('facterversion').and_return('3.99.0') |
| 138 | + allow(Puppet::Util::Execution).to receive(:execute).with(/puppet facts show --no-facterng/).and_return(facter3_facts) |
| 139 | + allow(Puppet::Util::Execution).to receive(:execute).with(/puppet facts show --facterng/).and_return(facter4_facts) |
| 140 | + end |
| 141 | + |
| 142 | + shared_examples_for 'correctly rendering output' do |render_format| |
| 143 | + it 'correctly displays output' do |
| 144 | + app.command_line.args << '--render-as' << render_format if render_format |
| 145 | + expect { |
| 146 | + app.run |
| 147 | + }.to exit_with(0) |
| 148 | + .and output(expected_output).to_stdout |
| 149 | + end |
| 150 | + end |
| 151 | + |
| 152 | + context 'when formatting is set to default' do |
| 153 | + let(:expected_output) { <<~END } |
| 154 | + { |
| 155 | + "filesystems": { |
| 156 | + "new_value": "apfs,autofs,devfs", |
| 157 | + "old_value": "apfs,autofs" |
| 158 | + } |
| 159 | + } |
| 160 | + END |
| 161 | + |
| 162 | + it_behaves_like 'correctly rendering output' |
| 163 | + end |
| 164 | + |
| 165 | + context 'when formatting is set to yaml' do |
| 166 | + let(:expected_output) { <<~END } |
| 167 | + --- |
| 168 | + filesystems: |
| 169 | + :new_value: apfs,autofs,devfs |
| 170 | + :old_value: apfs,autofs |
| 171 | + END |
| 172 | + |
| 173 | + it_behaves_like 'correctly rendering output', 'yaml' |
| 174 | + end |
| 175 | + |
| 176 | + context 'when formatting is set to json' do |
| 177 | + let(:expected_output) { <<~END } |
| 178 | + {"filesystems":{"new_value":"apfs,autofs,devfs","old_value":"apfs,autofs"}} |
| 179 | + END |
| 180 | + |
| 181 | + it_behaves_like 'correctly rendering output', 'json' |
| 182 | + end |
| 183 | + end |
| 184 | + |
118 | 185 | context 'when default action is called' do
|
119 | 186 | before :each do
|
120 | 187 | Puppet::Node::Facts.indirection.terminus_class = :memory
|
|
0 commit comments