Skip to content

Commit

Permalink
Tests for the cache_directory
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune <[email protected]>
  • Loading branch information
Salim Afiune committed Nov 22, 2016
1 parent f986e9e commit 20858aa
Showing 1 changed file with 44 additions and 19 deletions.
63 changes: 44 additions & 19 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ def run_command(_cmd, options = {})

describe "configuration" do

let(:cache_directory_array) do
[
File.expand_path("~/.kitchen/cache"),
"/tmp/omnibus/cache",
"create: true"
]
end

%W[centos debian fedora opensuse ubuntu].each do |name|

context "for known bento platform names starting with #{name}" do
Expand Down Expand Up @@ -316,8 +324,8 @@ def run_command(_cmd, options = {})
expect(driver[:ssh]).to eq(:a => "b", :c => { :d => "e" })
end

it "sets :synced_folders to an empty array by default" do
expect(driver[:synced_folders]).to eq([])
it "sets :synced_folders with the cache_directory by default" do
expect(driver[:synced_folders]).to eq([cache_directory_array])
end

it "sets :synced_folders to a custom value" do
Expand All @@ -326,7 +334,11 @@ def run_command(_cmd, options = {})
]

expect(driver[:synced_folders]).to eq([
[File.expand_path("/host_path"), "/vm_path", "create: true, type: :nfs"]
[
File.expand_path("/host_path"),
"/vm_path", "create: true, type: :nfs"
],
cache_directory_array
])
end

Expand All @@ -336,7 +348,8 @@ def run_command(_cmd, options = {})
]

expect(driver[:synced_folders]).to eq([
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"]
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"],
cache_directory_array
])
end

Expand All @@ -346,7 +359,8 @@ def run_command(_cmd, options = {})
]

expect(driver[:synced_folders]).to eq([
[File.expand_path("/kroot/a"), "/vm_path", "stuff"]
[File.expand_path("/kroot/a"), "/vm_path", "stuff"],
cache_directory_array
])
end

Expand All @@ -356,23 +370,11 @@ def run_command(_cmd, options = {})
]

expect(driver[:synced_folders]).to eq([
[File.expand_path("/host_path"), "/vm_path", "nil"]
[File.expand_path("/host_path"), "/vm_path", "nil"],
cache_directory_array
])
end

describe "when chef_omnibus_cache is set" do
before do
allow(driver_object).to receive(:chef_omnibus_cache).
and_return("/tmp/path")
end

it "adds the extra synced folder for omnibus cache" do
expect(driver[:synced_folders]).to eq([
[File.expand_path("~/.kitchen/cache"), "/tmp/path", "create: true"]
])
end
end

it "sets :vagrant_binary to 'vagrant' by default" do
expect(driver[:vagrant_binary]).to eq("vagrant")
end
Expand Down Expand Up @@ -431,6 +433,14 @@ def run_command(_cmd, options = {})

context "for windows os_types" do

let(:win_cache_directory_array) do
[
File.expand_path("~/.kitchen/cache"),
"$env:TEMP\\omnibus\\cache",
"create: true"
]
end

before { allow(platform).to receive(:os_type).and_return("windows") }

it "sets :vm_hostname to nil by default" do
Expand All @@ -442,6 +452,21 @@ def run_command(_cmd, options = {})

expect(driver[:vm_hostname]).to eq("this-is-a--k")
end

it "sets :synced_folders with the cache_directory by default" do
expect(driver[:synced_folders]).to eq([win_cache_directory_array])
end

it "replaces %{instance_name} with instance name in :synced_folders" do
config[:synced_folders] = [
["/root/%{instance_name}", "/vm_path", "stuff"]
]

expect(driver[:synced_folders]).to eq([
[File.expand_path("/root/suitey-fooos-99"), "/vm_path", "stuff"],
win_cache_directory_array
])
end
end
end

Expand Down

0 comments on commit 20858aa

Please sign in to comment.