Skip to content

Commit c4f0e6a

Browse files
committed
Add tests demonstrating expected behavior for :from_facts and :to_facts
1 parent 3f3c654 commit c4f0e6a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec/octocatalog-diff/tests/cli/options/fact_file_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@
5050
end
5151

5252
describe '#opt_to_fact_file' do
53+
let(:fact_file) { OctocatalogDiff::Spec.fixture_path('facts/facts.yaml') }
54+
let(:fact_answer) do
55+
{
56+
'name' => 'rspec-node.xyz.github.net',
57+
'values' => {
58+
'apt_update_last_success' => 1_458_162_123,
59+
'architecture' => 'amd64',
60+
'datacenter' => 'xyz',
61+
'fqdn' => 'rspec-node.xyz.github.net'
62+
}
63+
}
64+
end
65+
5366
it 'should distinguish between the to-facts and from-facts' do
5467
fact_file_1 = OctocatalogDiff::Spec.fixture_path('facts/facts.yaml')
5568
fact_file_2 = OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml')
@@ -73,5 +86,23 @@
7386

7487
expect(result[:facts]).to eq(result[:to_facts])
7588
end
89+
90+
it 'should only define from-fact-file when only --from-fact-file is given' do
91+
result = run_optparse(['--from-fact-file', fact_file])
92+
expect(result[:from_facts].facts).to eq(fact_answer)
93+
expect(result[:to_facts]).to be_nil
94+
end
95+
96+
it 'should only define to-fact-file when only --to-fact-file is given' do
97+
result = run_optparse(['--from-fact-file', fact_file])
98+
expect(result[:from_facts]).to be_nil
99+
expect(result[:to_facts].facts).to eq(fact_answer)
100+
end
101+
102+
it 'should define both from and to fact file when --fact-file is given' do
103+
result = run_optparse(['--fact-file', fact_file])
104+
expect(result[:from_facts].facts).to eq(fact_answer)
105+
expect(result[:to_facts].facts).to eq(fact_answer)
106+
end
76107
end
77108
end

0 commit comments

Comments
 (0)