spec/beaker/hypervisor/aws_sdk_spec.rb in beaker-aws-0.8.0 vs spec/beaker/hypervisor/aws_sdk_spec.rb in beaker-aws-0.8.1

- old
+ new

@@ -1232,23 +1232,29 @@ key_pair = instance_double(Aws::EC2::Types::KeyPairInfo, :key_name => 'a-key') key_pair_result = instance_double(Aws::EC2::Types::DescribeKeyPairsResult, :key_pairs => [key_pair]) allow(aws).to receive(:ensure_key_pair).and_return(key_pair_result) end + it 'raises an error when associate_public_ip_address is included without subnet_id' do + host = @hosts[0] + host['associate_public_ip_address'] = true + expect{ aws.create_instance(host, amispec, nil) }.to raise_error("A subnet_id must be provided when configuring assoc_pub_ip_addr") + end + it 'sets associate_public_ip_address when included' do host = @hosts[0] host['associate_public_ip_address'] = true variable_path = hash_including( :network_interfaces => [hash_including(:associate_public_ip_address => true)]) reservation = instance_double(Aws::EC2::Types::Reservation, :instances => [instance_double(Aws::EC2::Types::Instance)]) expect(mock_client).to receive(:run_instances).with(variable_path).and_return(reservation) - aws.create_instance(host, amispec, nil) + aws.create_instance(host, amispec, "subnetfoo") end - it 'omits associate_public_ip_address when not included' do + it 'omits network_interfaces and associate_public_ip_address when not included, instead using subnet_id' do host = @hosts[0] variable_path = hash_including( - :network_interfaces => [hash_excluding(:associate_public_ip_address => anything)]) + :subnet_id => nil) reservation = instance_double(Aws::EC2::Types::Reservation, :instances => [instance_double(Aws::EC2::Types::Instance)]) expect(mock_client).to receive(:run_instances).with(variable_path).and_return(reservation) aws.create_instance(host, amispec, nil) end end