|
50 | 50 | end
|
51 | 51 |
|
52 | 52 | 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 | + |
53 | 66 | it 'should distinguish between the to-facts and from-facts' do
|
54 | 67 | fact_file_1 = OctocatalogDiff::Spec.fixture_path('facts/facts.yaml')
|
55 | 68 | fact_file_2 = OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml')
|
|
73 | 86 |
|
74 | 87 | expect(result[:facts]).to eq(result[:to_facts])
|
75 | 88 | 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 |
76 | 107 | end
|
77 | 108 | end
|
0 commit comments