Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Fix kitchen doctor Acceptance (#497)
Browse files Browse the repository at this point in the history
* Increase doctor code coverage

* Fail doctor task if issues aren't detected

* Use doctor Rake task in acceptance

* Add missing OS to doctor task invocation

---------

Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com>
  • Loading branch information
aaron-lane and Aaron Lane authored Feb 5, 2023
1 parent d84ef01 commit 23c8710
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,7 @@ jobs:
rake test:kitchen:backend-ssh-ubuntu
- name: Run Kitchen doctor
run: |
status=0
output="$(rake test:kitchen:doctor-${{ matrix.operating-system }})"
if [[ $output != *"${{ matrix.operating-system }}.driver.client"* ]]
then
echo "kitchen doctor did not detect driver.client error"
status=1
fi
if [[ $output != *"${{ matrix.operating-system }}.verifier.systems"* ]]
then
echo "kitchen doctor did not detect verifier.systems error"
status=1
fi
exit $status
rake test:kitchen:doctor-${{ matrix.operating-system }}
release:
name: "Release"
Expand Down
15 changes: 14 additions & 1 deletion spec/lib/kitchen/terraform/driver/doctor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
end

specify "should raise a user error" do
specify "should return true" do
expect(subject.call(config: config)).to be_truthy
end

Expand All @@ -58,5 +58,18 @@
end
end
end

context "when the configured client does exist and is executable" do
let :config do
{
# Use the current executable
client: $0
}
end

specify "should return false" do
expect(subject.call(config: config)).to be_falsey
end
end
end
end
15 changes: 15 additions & 0 deletions spec/lib/kitchen/terraform/verifier/doctor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

require "kitchen"
require "kitchen/terraform/system"
require "kitchen/terraform/verifier/doctor"
require "tempfile"

Expand All @@ -39,5 +40,19 @@
expect(subject.call(config: config)).to be_truthy
end
end

context "when the configured systems are not empty" do
let :config do
{
systems: [
::Kitchen::Terraform::System.new(configuration_attributes: {}, logger: logger)
]
}
end

specify "should return false" do
expect(subject.call(config: config)).to be_falsey
end
end
end
end
4 changes: 3 additions & 1 deletion test/kitchen/terraform/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def define_doctor
end.each_pair do |platform_name, instances|
desc "Run doctor-#{platform_name} test"
task "doctor-#{platform_name}" do
instances.each_entry(&:doctor_action)
instances.each_entry do |instance|
instance.doctor_action or raise "doctor did not detect an issue"
end
end
end
end
Expand Down

0 comments on commit 23c8710

Please sign in to comment.