|
2 | 2 |
|
3 | 3 | # This just gives us a hook so that we can call the function later on |
4 | 4 | describe 'simplib::stages', type: :class do |
5 | | - let(:pre_condition) do |
6 | | - <<~END |
7 | | - define mydef::test ( |
8 | | - $attribute = simplib::dlookup('mydef::test', 'attribute', $title, { 'default_value' => 'lucille2' }) |
9 | | - ) { |
10 | | - notify { "$title says": message => $attribute } |
11 | | - } |
| 5 | + on_supported_os.each do |os, os_facts| |
| 6 | + context "on #{os}" do |
| 7 | + let(:facts) { os_facts } |
| 8 | + let(:pre_condition) do |
| 9 | + <<~END |
| 10 | + define mydef::test ( |
| 11 | + $attribute = simplib::dlookup('mydef::test', 'attribute', $title, { 'default_value' => 'lucille2' }) |
| 12 | + ) { |
| 13 | + notify { "$title says": message => $attribute } |
| 14 | + } |
12 | 15 |
|
13 | | - define mydef::othertest ( |
14 | | - $attribute = simplib::dlookup('mydef::test', 'attribute', { 'default_value' => 'lucille2' }) |
15 | | - ) { |
16 | | - notify { "other $title says": message => $attribute } |
17 | | - } |
| 16 | + define mydef::othertest ( |
| 17 | + $attribute = simplib::dlookup('mydef::test', 'attribute', { 'default_value' => 'lucille2' }) |
| 18 | + ) { |
| 19 | + notify { "other $title says": message => $attribute } |
| 20 | + } |
18 | 21 |
|
19 | | - mydef::test { 'gob': } |
20 | | - mydef::test { 'tobias': } |
21 | | - mydef::test { 'michael': attribute => 'bananastand' } |
| 22 | + mydef::test { 'gob': } |
| 23 | + mydef::test { 'tobias': } |
| 24 | + mydef::test { 'michael': attribute => 'bananastand' } |
22 | 25 |
|
23 | | - mydef::othertest { 'gob': } |
24 | | - mydef::othertest { 'tobias': } |
25 | | - mydef::othertest { 'michael': attribute => 'bananastand' } |
26 | | - END |
27 | | - end |
| 26 | + mydef::othertest { 'gob': } |
| 27 | + mydef::othertest { 'tobias': } |
| 28 | + mydef::othertest { 'michael': attribute => 'bananastand' } |
| 29 | + END |
| 30 | + end |
28 | 31 |
|
29 | | - let(:gob) { catalogue.resource('Mydef::Test[gob]') } |
30 | | - let(:tobias) { catalogue.resource('Mydef::Test[tobias]') } |
31 | | - let(:michael) { catalogue.resource('Mydef::Test[michael]') } |
| 32 | + let(:gob) { catalogue.resource('Mydef::Test[gob]') } |
| 33 | + let(:tobias) { catalogue.resource('Mydef::Test[tobias]') } |
| 34 | + let(:michael) { catalogue.resource('Mydef::Test[michael]') } |
32 | 35 |
|
33 | | - let(:gob_other) { catalogue.resource('Mydef::Othertest[gob]') } |
34 | | - let(:tobias_other) { catalogue.resource('Mydef::Othertest[tobias]') } |
35 | | - let(:michael_other) { catalogue.resource('Mydef::Othertest[michael]') } |
| 36 | + let(:gob_other) { catalogue.resource('Mydef::Othertest[gob]') } |
| 37 | + let(:tobias_other) { catalogue.resource('Mydef::Othertest[tobias]') } |
| 38 | + let(:michael_other) { catalogue.resource('Mydef::Othertest[michael]') } |
36 | 39 |
|
37 | | - it { is_expected.to compile.with_all_deps } |
| 40 | + it { is_expected.to compile.with_all_deps } |
38 | 41 |
|
39 | | - context 'no overrides' do |
40 | | - it { expect(gob[:attribute]).to eq('lucille2') } |
41 | | - it { expect(tobias[:attribute]).to eq('lucille2') } |
42 | | - it { expect(michael[:attribute]).to eq('bananastand') } |
43 | | - it { expect(gob_other[:attribute]).to eq('lucille2') } |
44 | | - it { expect(tobias_other[:attribute]).to eq('lucille2') } |
45 | | - it { expect(michael_other[:attribute]).to eq('bananastand') } |
46 | | - end |
| 42 | + context 'no overrides' do |
| 43 | + it { expect(gob[:attribute]).to eq('lucille2') } |
| 44 | + it { expect(tobias[:attribute]).to eq('lucille2') } |
| 45 | + it { expect(michael[:attribute]).to eq('bananastand') } |
| 46 | + it { expect(gob_other[:attribute]).to eq('lucille2') } |
| 47 | + it { expect(tobias_other[:attribute]).to eq('lucille2') } |
| 48 | + it { expect(michael_other[:attribute]).to eq('bananastand') } |
| 49 | + end |
47 | 50 |
|
48 | | - context 'overrides' do |
49 | | - let(:facts) do |
50 | | - { |
51 | | - cache_bust: Time.now.to_s, |
52 | | - hieradata: 'simplib_dlookup_overrides', |
53 | | - } |
54 | | - end |
| 51 | + context 'overrides' do |
| 52 | + let(:facts) do |
| 53 | + os_facts.merge( |
| 54 | + cache_bust: Time.now.to_s, |
| 55 | + hieradata: 'simplib_dlookup_overrides', |
| 56 | + ) |
| 57 | + end |
55 | 58 |
|
56 | | - let(:hieradata) { 'simplib_dlookup_overrides' } |
| 59 | + let(:hieradata) { 'simplib_dlookup_overrides' } |
57 | 60 |
|
58 | | - context 'with global overrides' do |
59 | | - it { expect(gob[:attribute]).to eq('illusions') } |
60 | | - it { expect(gob_other[:attribute]).to eq('illusions') } |
61 | | - it { expect(tobias_other[:attribute]).to eq('illusions') } |
62 | | - end |
63 | | - context 'with specific overrides' do |
64 | | - it { expect(tobias[:attribute]).to eq('blueman') } |
65 | | - end |
66 | | - context 'with a static value' do |
67 | | - it { expect(michael[:attribute]).to eq('bananastand') } |
68 | | - it { expect(michael_other[:attribute]).to eq('bananastand') } |
| 61 | + context 'with global overrides' do |
| 62 | + it { expect(gob[:attribute]).to eq('illusions') } |
| 63 | + it { expect(gob_other[:attribute]).to eq('illusions') } |
| 64 | + it { expect(tobias_other[:attribute]).to eq('illusions') } |
| 65 | + end |
| 66 | + context 'with specific overrides' do |
| 67 | + it { expect(tobias[:attribute]).to eq('blueman') } |
| 68 | + end |
| 69 | + context 'with a static value' do |
| 70 | + it { expect(michael[:attribute]).to eq('bananastand') } |
| 71 | + it { expect(michael_other[:attribute]).to eq('bananastand') } |
| 72 | + end |
| 73 | + end |
69 | 74 | end |
70 | 75 | end |
71 | 76 | end |
0 commit comments