Skip to content

Commit 6b4f9f2

Browse files
author
Kevin Paulisse
committed
Finish integration test and corresponding feature
1 parent 651cb88 commit 6b4f9f2

9 files changed

Lines changed: 105 additions & 16 deletions

File tree

spec/octocatalog-diff/fixtures/repos/yaml-diff/hiera.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:yaml:
55
:datadir: /var/lib/puppet/environments/%{::environment}/hieradata
66
:hierarchy:
7-
- roles/%{::reference_validation_role}
7+
- roles/%{::role}
88
- common
99
:merge_behavior: deeper
1010
:logger: console
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
structure:
3+
value: bar
4+
array:
5+
- foo
6+
- bar
7+
- baz
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
value: <%= @parameter %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
value: nachos
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "title": "This is not YAML", "value": "<%= @parameter %>" }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
<% if @parameter == 'default' %>
3+
structure:
4+
value: bar
5+
array:
6+
- foo
7+
- bar
8+
- baz
9+
<% else %>
10+
structure:
11+
value: bar
12+
array:
13+
- foo
14+
- bar
15+
- baz
16+
<% end %>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--- !ruby/object:This::Does::Not::Exist
2+
name: foo
3+
value: baz
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--- !ruby/object:This::Does::Not::Exist
2+
name: foo
3+
value: <%= @parameter %>

spec/octocatalog-diff/integration/yaml_diff_spec.rb

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,85 @@
44
require 'json'
55

66
describe 'YAML file suppression for identical diffs' do
7-
let(:argv) { ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar'] }
8-
let(:hash) do
9-
{
10-
hiera_config: 'hiera.yaml',
11-
spec_fact_file: 'facts.yaml',
12-
spec_repo: 'yaml-diff'
13-
}
14-
end
15-
167
context 'with YAML diff suppression disabled' do
17-
let(:result) { OctocatalogDiff::Integration.integration(hash.merge(argv: argv)) }
8+
before(:all) do
9+
argv = ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar']
10+
hash = { hiera_config: 'hiera.yaml', spec_fact_file: 'facts.yaml', spec_repo: 'yaml-diff' }
11+
@result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
12+
end
1813

1914
it 'should compile without error' do
20-
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
21-
expect(result.exception).to be_nil
15+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
16+
expect(@result.exception).to be_nil
17+
end
18+
19+
it 'should contain the correct number of diffs' do
20+
expect(@result.diffs.size).to eq(22)
21+
end
22+
23+
it 'should contain the "similar JSON" static file as a diff' do
24+
arr = @result.diffs
25+
answer = ['~', "File\f/tmp/static/similar-yaml.json\fparameters\fcontent"]
26+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
27+
end
28+
29+
it 'should contain the "similar YAML" static file as a diff' do
30+
arr = @result.diffs
31+
answer = ['~', "File\f/tmp/static/similar-yaml.yaml\fparameters\fcontent"]
32+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
33+
end
34+
35+
it 'should contain the "similar JSON" template file as a diff' do
36+
arr = @result.diffs
37+
answer = ['~', "File\f/tmp/template/similar-yaml.json\fparameters\fcontent"]
38+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
39+
end
40+
41+
it 'should contain the "similar YAML" template file as a diff' do
42+
arr = @result.diffs
43+
answer = ['~', "File\f/tmp/template/similar-yaml.yaml\fparameters\fcontent"]
44+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
2245
end
2346
end
2447

2548
context 'with YAML diff suppression enabled' do
26-
let(:result) { OctocatalogDiff::Integration.integration(hash.merge(argv: argv + ['--ignore-yaml-whitespace'])) }
49+
before(:all) do
50+
argv = ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar', '--ignore-equivalent-yaml-files']
51+
hash = { hiera_config: 'hiera.yaml', spec_fact_file: 'facts.yaml', spec_repo: 'yaml-diff' }
52+
@result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
53+
end
2754

2855
it 'should compile without error' do
29-
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
30-
expect(result.exception).to be_nil
56+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
57+
expect(@result.exception).to be_nil
58+
end
59+
60+
it 'should contain the correct number of diffs' do
61+
expect(@result.diffs.size).to eq(20)
62+
end
63+
64+
it 'should contain the "similar JSON" static file as a diff' do
65+
arr = @result.diffs
66+
answer = ['~', "File\f/tmp/static/similar-yaml.json\fparameters\fcontent"]
67+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
68+
end
69+
70+
it 'should not contain the "similar YAML" static file as a diff' do
71+
arr = @result.diffs
72+
answer = ['~', "File\f/tmp/static/similar-yaml.yaml\fparameters\fcontent"]
73+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(false)
74+
end
75+
76+
it 'should contain the "similar JSON" template file as a diff' do
77+
arr = @result.diffs
78+
answer = ['~', "File\f/tmp/template/similar-yaml.json\fparameters\fcontent"]
79+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true)
80+
end
81+
82+
it 'should not contain the "similar YAML" template file as a diff' do
83+
arr = @result.diffs
84+
answer = ['~', "File\f/tmp/template/similar-yaml.yaml\fparameters\fcontent"]
85+
expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(false)
3186
end
3287
end
3388
end

0 commit comments

Comments
 (0)