Skip to content

Commit c3b8593

Browse files
authored
Merge pull request #104 from barkingfoodog/add-windows-tests
Added platform-specific tests
2 parents c2ad48d + 36ecba4 commit c3b8593

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

spec/kitchen/provisioner/salt_solo_spec.rb

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
let(:logged_output) { StringIO.new }
4242
let(:logger) { Logger.new(logged_output) }
4343
let(:platform) do
44-
instance_double(Kitchen::Platform, os_type: nil)
44+
instance_double(Kitchen::Platform, os_type: 'unix')
4545
end
4646

4747
let(:config) do
@@ -113,8 +113,20 @@
113113
describe '#init_command' do
114114
subject { provisioner.init_command }
115115

116-
it 'should give a sane command' do
117-
is_expected.to match(/mkdir/)
116+
context 'when unix' do
117+
it 'should give a sane command' do
118+
is_expected.to match(/mkdir/)
119+
end
120+
end
121+
122+
context 'when windows' do
123+
let(:platform) do
124+
instance_double(Kitchen::Platform, os_type: 'windows')
125+
end
126+
127+
it 'should use powershell' do
128+
is_expected.to match(/mkdir -Force -Path/)
129+
end
118130
end
119131
end
120132

@@ -129,8 +141,20 @@
129141
{}
130142
end
131143

132-
it 'should give a sane run_command' do
133-
is_expected.to match(/salt-call/)
144+
context 'when unix' do
145+
it 'should give a sane run_command' do
146+
is_expected.to match(/salt-call/)
147+
end
148+
end
149+
150+
context 'when windows' do
151+
let(:platform) do
152+
instance_double(Kitchen::Platform, os_type: 'windows')
153+
end
154+
155+
it 'should use salt-call.bat' do
156+
is_expected.to match(/c:\\salt\\salt-call.bat /)
157+
end
134158
end
135159

136160
it 'should not include extra logic to detect failures' do
@@ -194,6 +218,22 @@
194218

195219
it { is_expected.to include 'https://bootstrap.saltstack.org' }
196220

221+
context "when unix" do
222+
it "should use apt-get" do
223+
expect(provisioner.install_command).to match(/apt-get/)
224+
end
225+
end
226+
227+
context "when windows" do
228+
let(:platform) do
229+
instance_double(Kitchen::Platform, os_type: 'windows')
230+
end
231+
232+
it "should use powershell" do
233+
expect(provisioner.install_command).to match(/powershell/)
234+
end
235+
end
236+
197237
context 'with salt version 2016.03.1' do
198238
let(:salt_version) { '2016.03.1' }
199239
let(:config) do

0 commit comments

Comments
 (0)