Skip to content

Commit

Permalink
add tests for the :rackconnect_wait config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-jansen committed Sep 10, 2014
1 parent 906a4dd commit 024bb33
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions spec/kitchen/driver/rackspace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,61 @@
end
end

describe '#create and rackconnect_wait' do
let(:server) do
double(id: 'test123',
wait_for: true,
public_ip_address: '1.2.3.4',
private_ip_address: '10.9.8.7',
update: nil)
end
let(:driver) do
config[:rackconnect_wait] = true
d = Kitchen::Driver::Rackspace.new(config)
d.instance = instance
allow(d).to receive(:default_name).and_return('a_monkey!')
allow(d).to receive(:create_server).and_return(server)
allow(d).to receive(:tcp_check).and_return(true)
d
end

context 'username and API key only provided' do
let(:config) do
{
rackspace_username: 'hello',
rackspace_api_key: 'world',
wait_for: 1200
}
end

it 'generates a server name in the absence of one' do
driver.create(state)
expect(driver[:server_name]).to eq('a_monkey!')
end

it 'gets a proper server ID' do
driver.create(state)
expect(state[:server_id]).to eq('test123')
end

it 'gets a proper hostname (IP)' do
driver.create(state)
expect(state[:hostname]).to eq('1.2.3.4')
end

it 'calls tcp_check' do
expect(driver).to receive(:tcp_check)
driver.create(state)
end

it 'calls rackconnect_check and wait_for twice' do
expect(driver).to receive(:rackconnect_check)
expect(server).to receive(:wait_for).twice
driver.create(state)
end
end
end

describe '#create and use_private_ip_address' do
let(:server) do
double(id: 'test123',
Expand Down

0 comments on commit 024bb33

Please sign in to comment.