Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #217 from dtan4/increase-test-cov-160528
Browse files Browse the repository at this point in the history
Increase test coverage
  • Loading branch information
dtan4 committed May 28, 2016
2 parents 8aadb92 + 9b5ca24 commit 22dbd06
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/dtan4/terraforming.svg?branch=master)](https://travis-ci.org/dtan4/terraforming)
[![Code Climate](https://codeclimate.com/github/dtan4/terraforming/badges/gpa.svg)](https://codeclimate.com/github/dtan4/terraforming)
[![Test Coverage](https://codeclimate.com/github/dtan4/terraforming/badges/coverage.svg)](https://codeclimate.com/github/dtan4/terraforming)
[![Coverage Status](https://coveralls.io/repos/github/dtan4/terraforming/badge.svg?branch=increase-test-cov-160528)](https://coveralls.io/github/dtan4/terraforming)
[![Dependency Status](https://gemnasium.com/dtan4/terraforming.svg)](https://gemnasium.com/dtan4/terraforming)
[![Gem Version](https://badge.fury.io/rb/terraforming.svg)](http://badge.fury.io/rb/terraforming)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
Expand Down
16 changes: 4 additions & 12 deletions lib/terraforming/resource/route_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,12 @@ def route_attributes_of(route)
end

def route_hashcode_of(route)
string = "#{route.destination_cidr_block}-" <<
"#{route.gateway_id}-"

instance_set = false
if route.instance_id != ''
string << route.instance_id.to_s
instance_set = true
end
string = "#{route.destination_cidr_block}-#{route.gateway_id}-"
instance_set = !route.instance_id.nil? && route.instance_id != ''

string << route.instance_id.to_s if instance_set
string << route.vpc_peering_connection_id.to_s

unless instance_set
string << route.network_interface_id.to_s
end
string << route.network_interface_id.to_s unless instance_set

Zlib.crc32(string)
end
Expand Down
103 changes: 103 additions & 0 deletions spec/lib/terraforming/resource/security_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,51 @@ module Resource
tags: [
{ key: "Name", value: "fuga" }
]
},
{
owner_id: "098765432109",
group_name: "piyo",
group_id: "sg-9012ijkl",
description: "Group for piyo",
vpc_id: "vpc-1234abcd",
ip_permissions: [
{
ip_protocol: "tcp",
from_port: 22,
to_port: 22,
user_id_group_pairs: [
{
user_id: "098765432109",
group_name: nil,
group_id: "sg-9012ijkl"
}
],
ip_ranges: []
},
{
ip_protocol: "tcp",
from_port: 22,
to_port: 22,
user_id_group_pairs: [],
ip_ranges: [
{ cidr_ip: "0.0.0.0/0" }
]
},
],
ip_permissions_egress: [
{
ip_protocol: "-1",
from_port: 1,
to_port: 65535,
user_id_group_pairs: [],
ip_ranges: [
{ cidr_ip: "0.0.0.0/0" }
]
},
],
tags: [
{ key: "Name", value: "piyo" }
]
}
]
end
Expand Down Expand Up @@ -178,6 +223,33 @@ module Resource
}
}
resource "aws_security_group" "vpc-1234abcd-piyo" {
name = "piyo"
description = "Group for piyo"
vpc_id = "vpc-1234abcd"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_groups = []
self = true
}
egress {
from_port = 1
to_port = 65535
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
"Name" = "piyo"
}
}
EOS
end
end
Expand Down Expand Up @@ -254,6 +326,37 @@ module Resource
}
}
},
"aws_security_group.vpc-1234abcd-piyo" => {
"type" => "aws_security_group",
"primary" => {
"id" => "sg-9012ijkl",
"attributes" => {
"description" => "Group for piyo",
"id" => "sg-9012ijkl",
"name" => "piyo",
"owner_id" => "098765432109",
"vpc_id" => "vpc-1234abcd",
"tags.#" => "1",
"tags.Name" => "piyo",
"egress.#" => "1",
"egress.1899000807.from_port" => "1",
"egress.1899000807.to_port" => "65535",
"egress.1899000807.protocol" => "-1",
"egress.1899000807.cidr_blocks.#" => "1",
"egress.1899000807.security_groups.#" => "0",
"egress.1899000807.self" => "false",
"egress.1899000807.cidr_blocks.0" => "0.0.0.0/0",
"ingress.#" => "1",
"ingress.1905676327.from_port" => "22",
"ingress.1905676327.to_port" => "22",
"ingress.1905676327.protocol" => "tcp",
"ingress.1905676327.cidr_blocks.#" => "1",
"ingress.1905676327.security_groups.#" => "0",
"ingress.1905676327.self" => "true",
"ingress.1905676327.cidr_blocks.0" => "0.0.0.0/0",
}
}
},
})
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require "codeclimate-test-reporter"
require "coveralls"
require "simplecov"

SimpleCov.start do
formatter SimpleCov::Formatter::MultiFormatter.new([
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter,
])
end

Expand Down
2 changes: 1 addition & 1 deletion terraforming.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "thor"

spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "codeclimate-test-reporter"
spec.add_development_dependency "coveralls", "~> 0.8.13"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.2"
spec.add_development_dependency "simplecov", "~> 0.11.1"
Expand Down

0 comments on commit 22dbd06

Please sign in to comment.