-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command
awspec generate directconnect
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
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
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
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,33 @@ | ||
module Awspec::Generator | ||
module Spec | ||
class Directconnect | ||
include Awspec::Helper::Finder | ||
def generate_all | ||
generate_virtual_interface_all | ||
end | ||
|
||
def generate_virtual_interface_all | ||
virtual_interfaces = select_virtual_interfaces | ||
virtual_interfaces.empty? && fail('Not Found virtual_interfaces') | ||
ERB.new(virtual_interface_spec_template, nil, '-').result(binding).chomp | ||
end | ||
|
||
def virtual_interface_spec_template | ||
template = <<-'EOF' | ||
<% virtual_interfaces.each do |interface| %> | ||
describe directconnect_virtual_interface('<%= interface.virtual_interface_name %>') do | ||
it { should exist } | ||
it { should be_<%= interface.virtual_interface_state %> } | ||
its(:connection_id) { should eq '<%= interface.connection_id %>' } | ||
its(:virtual_interface_id) { should eq '<%= interface.virtual_interface_id %>' } | ||
its(:amazon_address) { should eq '<%= interface.amazon_address %>' } | ||
its(:customer_address) { should eq '<%= interface.customer_address %>' } | ||
its(:virtual_gateway_id) { should eq '<%= interface.virtual_gateway_id %>' } | ||
end | ||
<% end %> | ||
EOF | ||
template | ||
end | ||
end | ||
end | ||
end |
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
23 changes: 23 additions & 0 deletions
23
spec/generator/spec/directconnect_virtual_interface_spec.rb
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,23 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Awspec::Generator::Spec::Directconnect' do | ||
before do | ||
Awspec::Stub.load 'directconnect_virtual_interface' | ||
end | ||
let(:directconnect) { Awspec::Generator::Spec::Directconnect.new } | ||
it 'generate_by_vpc_id generate spec' do | ||
spec = <<-'EOF' | ||
describe directconnect_virtual_interface('my-directconnect-virtual-interface') do | ||
it { should exist } | ||
it { should be_available } | ||
its(:connection_id) { should eq 'dxcon-abcd5fgh' } | ||
its(:virtual_interface_id) { should eq 'dxvif-aabbccdd' } | ||
its(:amazon_address) { should eq '170.252.252.1/30' } | ||
its(:customer_address) { should eq '123.456.789.2/30' } | ||
its(:virtual_gateway_id) { should eq 'vgw-d234e5f6' } | ||
end | ||
EOF | ||
expect(directconnect.generate_all.to_s.gsub(/\n/, "\n")).to eq spec | ||
end | ||
end |