Skip to content

Commit d8f249b

Browse files
committed
Create integration test for multiple fact files
1 parent 9a664a5 commit d8f249b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- !ruby/object:Puppet::Node::Facts
2+
name: rspec-node.xyz.github.net
3+
values:
4+
_timestamp: '2016-03-16 16:02:13 -0500'
5+
apt_update_last_success: 1458162123
6+
architecture: amd64
7+
clientcert: rspec-node.github.net
8+
datacenter: xyz
9+
domain: xyz.github.net
10+
fqdn: rspec-node.xyz.github.net
11+
ipaddress: 10.30.50.70
12+
kernel: Linux
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'integration_helper'
4+
5+
require 'json'
6+
7+
describe 'fact files by branch' do
8+
before(:all) do
9+
@result = OctocatalogDiff::Integration.integration_cli(
10+
[
11+
'-n', 'rspec-node.github.net',
12+
'--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
13+
'--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
14+
'--output-format', 'json',
15+
'--fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'),
16+
'--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'),
17+
'--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY,
18+
'--fact-override', 'foofoo=barbar',
19+
'-d'
20+
]
21+
)
22+
end
23+
24+
it 'should exit with status 2' do
25+
expect(@result.exitcode).to eq(2), @result.stderr
26+
end
27+
28+
it 'should contain the correct diffs' do
29+
parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) }
30+
expect(parse_result.size).to eq(1)
31+
expect(parse_result).to include(
32+
'diff_type' => '~',
33+
'type' => 'File',
34+
'title' => '/tmp/ipaddress',
35+
'structure' => %w(parameters content),
36+
'old_value' => '10.20.30.40',
37+
'new_value' => '10.30.50.70'
38+
)
39+
end
40+
41+
it 'should log the correct messages' do
42+
expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/)
43+
expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/)
44+
expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
45+
end
46+
end

0 commit comments

Comments
 (0)