Skip to content

Commit e99be82

Browse files
committed
Create integration test demonstrating problem
1 parent b2f0c4d commit e99be82

File tree

1 file changed

+100
-2
lines changed

1 file changed

+100
-2
lines changed

spec/octocatalog-diff/integration/fact_file_by_branch_spec.rb

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
require 'json'
66

7-
describe 'fact files by branch' do
7+
describe 'fact files by branch, with two fact files' do
88
before(:all) do
99
@result = OctocatalogDiff::Integration.integration_cli(
1010
[
1111
'-n', 'rspec-node.github.net',
1212
'--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
1313
'--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
1414
'--output-format', 'json',
15-
'--fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'),
15+
'--from-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'),
1616
'--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'),
1717
'--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY,
1818
'--fact-override', 'foofoo=barbar',
@@ -44,3 +44,101 @@
4444
expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
4545
end
4646
end
47+
48+
describe 'fact files by branch, with only a to fact file' do
49+
before(:all) do
50+
@tmpdir = Dir.mktmpdir
51+
ENV['PUPPET_FACT_DIR'] = @tmpdir
52+
FileUtils.cp OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), File.join(@tmpdir, 'rspec-node.github.net.yaml')
53+
54+
@result = OctocatalogDiff::Integration.integration_cli(
55+
[
56+
'-n', 'rspec-node.github.net',
57+
'--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
58+
'--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
59+
'--output-format', 'json',
60+
'--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'),
61+
'--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY,
62+
'--fact-override', 'foofoo=barbar',
63+
'-d'
64+
]
65+
)
66+
end
67+
68+
after(:all) do
69+
ENV['PUPPET_FACT_DIR'] = nil
70+
OctocatalogDiff::Spec.clean_up_tmpdir(@tmpdir)
71+
end
72+
73+
it 'should exit with status 2' do
74+
expect(@result.exitcode).to eq(2), @result.stderr
75+
end
76+
77+
it 'should contain the correct diffs' do
78+
parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) }
79+
expect(parse_result.size).to eq(1)
80+
expect(parse_result).to include(
81+
'diff_type' => '~',
82+
'type' => 'File',
83+
'title' => '/tmp/ipaddress',
84+
'structure' => %w(parameters content),
85+
'old_value' => '10.20.30.40',
86+
'new_value' => '10.30.50.70'
87+
)
88+
end
89+
90+
it 'should log the correct messages' do
91+
expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/)
92+
expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/)
93+
expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
94+
end
95+
end
96+
97+
describe 'fact files by branch, with only a from fact file' do
98+
before(:all) do
99+
@tmpdir = Dir.mktmpdir
100+
ENV['PUPPET_FACT_DIR'] = @tmpdir
101+
FileUtils.cp OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), File.join(@tmpdir, 'rspec-node.github.net.yaml')
102+
103+
@result = OctocatalogDiff::Integration.integration_cli(
104+
[
105+
'-n', 'rspec-node.github.net',
106+
'--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
107+
'--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
108+
'--output-format', 'json',
109+
'--from-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'),
110+
'--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY,
111+
'--fact-override', 'foofoo=barbar',
112+
'-d'
113+
]
114+
)
115+
end
116+
117+
after(:all) do
118+
ENV['PUPPET_FACT_DIR'] = nil
119+
OctocatalogDiff::Spec.clean_up_tmpdir(@tmpdir)
120+
end
121+
122+
it 'should exit with status 2' do
123+
expect(@result.exitcode).to eq(2), @result.stderr
124+
end
125+
126+
it 'should contain the correct diffs' do
127+
parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) }
128+
expect(parse_result.size).to eq(1)
129+
expect(parse_result).to include(
130+
'diff_type' => '~',
131+
'type' => 'File',
132+
'title' => '/tmp/ipaddress',
133+
'structure' => %w(parameters content),
134+
'new_value' => '10.20.30.40',
135+
'old_value' => '10.30.50.70'
136+
)
137+
end
138+
139+
it 'should log the correct messages' do
140+
expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/)
141+
expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/)
142+
expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
143+
end
144+
end

0 commit comments

Comments
 (0)