Skip to content

Commit 9168352

Browse files
add some more checks
Signed-off-by: Lamont Granquist <[email protected]>
1 parent 718b039 commit 9168352

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

spec/unit/health_check_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,32 @@ def mkdump(base, size, x64 = false)
109109
)
110110
end
111111

112+
let(:empty_list) do
113+
double("Mixlib::Shellout",
114+
error!: false,
115+
stdout: <<~EOH
116+
EOH
117+
)
118+
end
119+
120+
let(:failed_list) do
121+
double("Mixlib::Shellout",
122+
error!: true,
123+
stdout: <<~EOH
124+
/opt/chefdk/shouldnt/matter
125+
EOH
126+
)
127+
end
128+
129+
let(:bad_list) do
130+
double("Mixlib::Shellout",
131+
error!: false,
132+
stdout: <<~EOH
133+
/somewhere/other/than/install/dir
134+
EOH
135+
)
136+
end
137+
112138
let(:bad_healthcheck) do
113139
double("Mixlib::Shellout",
114140
error!: false,
@@ -174,6 +200,30 @@ def mkdump(base, size, x64 = false)
174200
it "will not perform dll base relocation checks" do
175201
expect(subject.relocation_checkable?).to be false
176202
end
203+
204+
it "raises an exception if there's nothing in the file list" do
205+
allow(subject).to receive(:shellout)
206+
.with("find /opt/chefdk/ -type f")
207+
.and_return(empty_list)
208+
209+
expect { subject.run! }.to raise_error(HealthCheckFailed)
210+
end
211+
212+
it "raises an exception if the file list command raises" do
213+
allow(subject).to receive(:shellout)
214+
.with("find /opt/chefdk/ -type f")
215+
.and_return(failed_list)
216+
217+
expect { subject.run! }.to raise_error(HealthCheckFailed)
218+
end
219+
220+
it "raises an exception if the file list command has no entries in the install_dir" do
221+
allow(subject).to receive(:shellout)
222+
.with("find /opt/chefdk/ -type f")
223+
.and_return(bad_list)
224+
225+
expect { subject.run! }.to raise_error(HealthCheckFailed)
226+
end
177227
end
178228
end
179229
end

0 commit comments

Comments
 (0)