Skip to content

Commit 52cfed1

Browse files
committed
Added RSpec tests
1 parent 7b2e5a0 commit 52cfed1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

spec/defines/plugin_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@
1515

1616
context 'with defaults for all parameters' do
1717
it { is_expected.to compile.with_all_deps }
18-
it { is_expected.to contain_exec('plugin install foo/plugin:latest').with_command(%r{docker plugin install}) }
18+
it { is_expected.to contain_exec('plugin install foo/plugin:latest').with_command(%r{docker plugin install}).with_unless(%r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest}) }
1919
end
2020

2121
context 'with enabled => false' do
2222
let(:params) { { 'enabled' => false } }
2323

2424
it { is_expected.to compile.with_all_deps }
25-
it { is_expected.to contain_exec('disable foo/plugin:latest').with_command(%r{docker plugin disable}) }
25+
it { is_expected.to contain_exec('disable foo/plugin:latest').with_command(%r{docker plugin disable}).with_unless(%r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest}) }
2626
end
2727

2828
context 'with ensure => absent' do
2929
let(:params) { { 'ensure' => 'absent' } }
3030

3131
it { is_expected.to compile.with_all_deps }
32-
it { is_expected.to contain_exec('plugin remove foo/plugin:latest').with_command(%r{docker plugin rm}) }
32+
it { is_expected.to contain_exec('plugin remove foo/plugin:latest').with_command(%r{docker plugin rm}).with_onlyif(%r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest}) }
3333
end
34+
35+
context 'with alias => foo-plugin' do
36+
let(:params) { { 'plugin_alias' => 'foo-plugin' } }
37+
38+
it { is_expected.to contain_exec('plugin install foo/plugin:latest').with_command(%r{docker plugin install}).with_unless(%r{docker ls --format='{{.PluginReference}}' | grep -w foo/plugin:latest}) }
39+
end
40+
3441
end

0 commit comments

Comments
 (0)