-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(CAT-372) - Add tests for vagrant provision
- Loading branch information
1 parent
2b89d5a
commit 932a5aa
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'json' | ||
require 'rspec' | ||
|
||
describe 'vagrant' do | ||
before(:each) do | ||
# Stub $stdin.read to return a predefined JSON string | ||
allow($stdin).to receive(:read).and_return({ | ||
platform: 'generic/debian10', | ||
action: 'provision', | ||
vars: 'role: worker1', | ||
inventory: './spec/fixtures/litmus_inventory.yaml', | ||
enable_synced_folder: 'true', | ||
provider: 'provider', | ||
cpus: 'cpus', | ||
memory: 'memory', | ||
hyperv_vswitch: 'hyperv_vswitch', | ||
hyperv_smb_username: 'hyperv_smb_username' | ||
}.to_json) | ||
# Load the task file after stubbing $stdin, as the task file reads from $stdin on load | ||
require_relative '../../tasks/vagrant' | ||
end | ||
|
||
it 'provisions a new vagrant box when action is provision' do | ||
result = provision(platform, inventory_location, enable_synced_folder, provider, cpus, memory, hyperv_vswitch, hyperv_smb_username, hyperv_smb_password, box_url, password, vars) | ||
expect(result[:status]).to eq('ok') | ||
expect(result[:node_name]).not_to be_nil | ||
expect(result[:node]['facts']['provisioner']).to eq('vagrant') | ||
expect(result[:node]['facts']['platform']).to eq(platform) | ||
expect(result[:node]['vars']).to eq(JSON.parse(vars)) | ||
end | ||
end |