|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 |
| -describe 'docker::swarm', :type => :define do |
4 |
| - let(:title) { 'create swarm' } |
5 |
| - let(:facts) { { |
6 |
| - :osfamily => 'Debian', |
7 |
| - :operatingsystem => 'Debian', |
8 |
| - :lsbdistid => 'Debian', |
9 |
| - :lsbdistcodename => 'jessie', |
10 |
| - :kernelrelease => '3.2.0-4-amd64', |
11 |
| - :operatingsystemmajrelease => '8', |
12 |
| - } } |
| 3 | +['Debian', 'Windows'].each do |osfamily| |
| 4 | + describe 'docker::swarm', :type => :define do |
| 5 | + let(:title) { 'create swarm' } |
| 6 | + context "on #{osfamily}" do |
| 7 | + if osfamily == 'Debian' |
| 8 | + let(:facts) { { |
| 9 | + :osfamily => 'Debian', |
| 10 | + :operatingsystem => 'Debian', |
| 11 | + :lsbdistid => 'Debian', |
| 12 | + :lsbdistcodename => 'jessie', |
| 13 | + :kernelrelease => '3.2.0-4-amd64', |
| 14 | + :operatingsystemmajrelease => '8', |
| 15 | + } } |
| 16 | + elsif osfamily == 'Windows' |
| 17 | + let(:facts) { { |
| 18 | + :osfamily => 'Windows', |
| 19 | + :operatingsystem => 'Windows', |
| 20 | + :kernelrelease => '10.0.14393', |
| 21 | + :operatingsystemmajrelease => '2016', |
| 22 | + } } |
| 23 | + end |
13 | 24 |
|
14 |
| - context 'with ensure => present and swarm init' do |
15 |
| - let(:params) { { |
16 |
| - 'init' => true, |
17 |
| - 'advertise_addr' => '192.168.1.1', |
18 |
| - 'listen_addr' => '192.168.1.1', |
19 |
| - } } |
20 |
| - it { is_expected.to compile.with_all_deps } |
21 |
| - it { should contain_exec('Swarm init').with_command(/docker swarm init/) } |
22 |
| - end |
| 25 | + context 'with ensure => present and swarm init' do |
| 26 | + let(:params) { { |
| 27 | + 'init' => true, |
| 28 | + 'advertise_addr' => '192.168.1.1', |
| 29 | + 'listen_addr' => '192.168.1.1', |
| 30 | + } } |
| 31 | + it { is_expected.to compile.with_all_deps } |
| 32 | + it { should contain_exec('Swarm init').with_command(/docker swarm init/) } |
| 33 | + end |
23 | 34 |
|
24 |
| - context 'with ensure => present and swarm join' do |
25 |
| - let(:params) { { |
26 |
| - 'join' => true, |
27 |
| - 'advertise_addr' => '192.168.1.1', |
28 |
| - 'listen_addr' => '192.168.1.1', |
29 |
| - 'token' => 'foo', |
30 |
| - 'manager_ip' => '192.168.1.2' |
31 |
| - } } |
32 |
| - it { is_expected.to compile.with_all_deps } |
33 |
| - it { should contain_exec('Swarm join').with_command(/docker swarm join/) } |
34 |
| - end |
| 35 | + context 'with ensure => present and swarm join' do |
| 36 | + let(:params) { { |
| 37 | + 'join' => true, |
| 38 | + 'advertise_addr' => '192.168.1.1', |
| 39 | + 'listen_addr' => '192.168.1.1', |
| 40 | + 'token' => 'foo', |
| 41 | + 'manager_ip' => '192.168.1.2' |
| 42 | + } } |
| 43 | + it { is_expected.to compile.with_all_deps } |
| 44 | + it { should contain_exec('Swarm join').with_command(/docker swarm join/) } |
| 45 | + end |
35 | 46 |
|
36 |
| - context 'with ensure => absent' do |
37 |
| - let(:params) { { |
38 |
| - 'ensure' => 'absent', |
39 |
| - 'join' => true, |
40 |
| - 'advertise_addr' => '192.168.1.1', |
41 |
| - 'listen_addr' => '192.168.1.1', |
42 |
| - 'token' => 'foo', |
43 |
| - 'manager_ip' => '192.168.1.2' |
44 |
| - } } |
45 |
| - it { is_expected.to compile.with_all_deps } |
46 |
| - it { should contain_exec('Leave swarm').with_command(/docker swarm leave --force/) } |
| 47 | + context 'with ensure => absent' do |
| 48 | + let(:params) { { |
| 49 | + 'ensure' => 'absent', |
| 50 | + 'join' => true, |
| 51 | + 'advertise_addr' => '192.168.1.1', |
| 52 | + 'listen_addr' => '192.168.1.1', |
| 53 | + 'token' => 'foo', |
| 54 | + 'manager_ip' => '192.168.1.2' |
| 55 | + } } |
| 56 | + it { is_expected.to compile.with_all_deps } |
| 57 | + it { should contain_exec('Leave swarm').with_command(/docker swarm leave --force/) } |
| 58 | + end |
| 59 | + end |
47 | 60 | end
|
48 | 61 | end
|
0 commit comments