Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug can be occurred when instance returns nil #285

Merged
merged 2 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,13 @@ def local_kitchen_cache
# instance's Vagrantfile
# @api private
def vagrant_root
root = File.join(config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
)
@vagrant_root ||= instance.nil? ? nil : root
if !@vagrant_root && !instance.nil?
@vagrant_root = File.join(
config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
)
end
@vagrant_root
end

# @param type [Symbol] either `:ssh` or `:winrm`
Expand Down
10 changes: 10 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
d
end

let(:driver_with_no_instance) do
driver_object
end

let(:instance) do
Kitchen::Instance.new(
:verifier => verifier,
Expand Down Expand Up @@ -540,6 +544,12 @@ def run_command(_cmd, options = {})
driver.verify_dependencies
end

it "passes for supported versions of Vagrant when it has no instances" do
with_modern_vagrant

driver_with_no_instance.verify_dependencies
end

it "raises a UserError for unsupported versions of Vagrant" do
with_unsupported_vagrant

Expand Down