Permalink
Browse files

Update specs

  • Loading branch information...
ayemos committed Nov 28, 2018
1 parent b63e6c2 commit 86112cdac74bc503db01523b10af01801777a42a
Showing with 138 additions and 0 deletions.
  1. +1 −0 .travis.yml
  2. +33 −0 spec/roadworker_create_spec.rb
  3. +54 −0 spec/roadworker_delete_spec.rb
  4. +49 −0 spec/roadworker_update_spec.rb
  5. +1 −0 spec/spec_helper.rb
@@ -11,6 +11,7 @@ env:
- TEST_AWS_SECRET_ACCESS_KEY=5xoTPeHNXy20gxNdip5yHGA4Tctw50BTUxs++E+0
- TEST_ELB=roadworker-1619064454.ap-northeast-1.elb.amazonaws.com.
- TEST_CF=dwq5bksfxh5xn.cloudfront.net.
- TEST_APIGW=$$PLEASE_FILL_IT$$
- TEST_DELAY=0.3
- TEST_VPC_REGION=ap-northeast-1
- TEST_VPC1=vpc-18f5097d
@@ -261,6 +261,39 @@
}
end

context 'A(Alias) record (API Gateway)' do
it {
routefile do
<<EOS
hosted_zone "winebarrel.jp" do
rrset "apigw.winebarrel.jp", "A" do
dns_name TEST_APIGW
end
end
EOS
end

zones = fetch_hosted_zones(@route53)
expect(zones.length).to eq(1)

zone = zones[0]
expect(zone.name).to eq("winebarrel.jp.")
expect(zone.resource_record_set_count).to eq(3)

rrsets = fetch_rrsets(@route53, zone.id)
expect(rrsets['winebarrel.jp.', 'NS'].ttl).to eq(172800)
expect(rrsets['winebarrel.jp.', 'SOA'].ttl).to eq(900)

a = rrsets['apigw.winebarrel.jp.', 'A']
expect(a.name).to eq("apigw.winebarrel.jp.")
expect(a.alias_target).to eq(Aws::Route53::Types::AliasTarget.new(
:hosted_zone_id => "Z1YSHQZHG15GKL",
:dns_name => TEST_APIGW,
:evaluate_target_health => false,
))
}
end

context 'A(Alias) record (This HostedZone)' do
it {
routefile do
@@ -341,6 +341,60 @@
}
end

context 'A(Alias) record (API Gateway)' do
before {
routefile do
<<EOS
hosted_zone "winebarrel.jp" do
rrset "info.winebarrel.jp", "A" do
ttl 123
resource_records(
"127.0.0.1",
"127.0.0.2"
)
end

rrset "apigw.winebarrel.jp", "A" do
dns_name TEST_APIGW
end
end
EOS
end
}

it {
routefile do
<<EOS
hosted_zone "winebarrel.jp" do
rrset "info.winebarrel.jp", "A" do
ttl 123
resource_records(
"127.0.0.1",
"127.0.0.2"
)
end
end
EOS
end

zones = fetch_hosted_zones(@route53)
expect(zones.length).to eq(1)

zone = zones[0]
expect(zone.name).to eq("winebarrel.jp.")
expect(zone.resource_record_set_count).to eq(3)

rrsets = fetch_rrsets(@route53, zone.id)
expect(rrsets['winebarrel.jp.', 'NS'].ttl).to eq(172800)
expect(rrsets['winebarrel.jp.', 'SOA'].ttl).to eq(900)

info = rrsets['info.winebarrel.jp.', 'A']
expect(info.name).to eq("info.winebarrel.jp.")
expect(info.ttl).to eq(123)
expect(rrs_list(info.resource_records.sort_by {|i| i.to_s })).to eq(["127.0.0.1", "127.0.0.2"])
}
end


context 'A(Alias) record (This HostedZone)' do
before {
@@ -433,6 +433,55 @@
}
end

context 'A record -> A(Alias) record (API Gateway)' do
before {
routefile do
<<EOS
hosted_zone "winebarrel.jp" do
rrset "apigw.winebarrel.jp", "A" do
ttl 123
resource_records(
"127.0.0.1",
"127.0.0.2"
)
end
end
EOS
end
}

it {
routefile do
<<EOS
hosted_zone "winebarrel.jp" do
rrset "apigw.winebarrel.jp", "A" do
dns_name TEST_APIGW
end
end
EOS
end

zones = fetch_hosted_zones(@route53)
expect(zones.length).to eq(1)

zone = zones[0]
expect(zone.name).to eq("winebarrel.jp.")
expect(zone.resource_record_set_count).to eq(3)

rrsets = fetch_rrsets(@route53, zone.id)
expect(rrsets['winebarrel.jp.', 'NS'].ttl).to eq(172800)
expect(rrsets['winebarrel.jp.', 'SOA'].ttl).to eq(900)

a = rrsets['apigw.winebarrel.jp.', 'A']
expect(a.name).to eq("apigw.winebarrel.jp.")
expect(a.alias_target).to eq(Aws::Route53::Types::AliasTarget.new(
:hosted_zone_id => "Z1YSHQZHG15GKL",
:dns_name => TEST_APIGW,
:evaluate_target_health => false,
))
}
end

context 'A record -> A(Alias) record (This HostedZone)' do
before {
routefile do
@@ -12,6 +12,7 @@

TEST_ELB = ENV['TEST_ELB']
TEST_CF = ENV['TEST_CF']
TEST_APIGW = ENV['TEST_APIGW']
TEST_VPC_REGION = ENV['TEST_VPC_REGION']
TEST_VPC1 = ENV['TEST_VPC1']
TEST_VPC2 = ENV['TEST_VPC2']

0 comments on commit 86112cd

Please sign in to comment.