Commit 74174bb4 authored by Daisuke Fujita's avatar Daisuke Fujita

Fix nesting module declation in specs

parent 3ad361a7
require "spec_helper"
module Terraforming::Resource
describe DBParameterGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
module Terraforming
module Resource
describe DBParameterGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
let(:db_parameter_groups) do
[
{
db_parameter_group_name: "default.mysql5.6",
db_parameter_group_family: "mysql5.6",
description: "Default parameter group for mysql5.6"
},
{
db_parameter_group_name: "default.postgres9.4",
db_parameter_group_family: "postgres9.4",
description: "Default parameter group for postgres9.4"
}
]
end
let(:db_parameter_groups) do
[
{
db_parameter_group_name: "default.mysql5.6",
db_parameter_group_family: "mysql5.6",
description: "Default parameter group for mysql5.6"
},
{
db_parameter_group_name: "default.postgres9.4",
db_parameter_group_family: "postgres9.4",
description: "Default parameter group for postgres9.4"
}
]
end
let(:mysql_parameters) do
[
{
parameter_name: "application_name",
parameter_value: nil,
description: "Name of the application",
source: "engine-default",
apply_type: "dynamic",
data_type: "string",
allowed_values: nil,
is_modifiable: true,
minimum_engine_version: nil,
apply_method: nil
},
{
parameter_name: "archive_command",
parameter_value: "/path/to/archive %p",
description: "Command to archive database",
source: "system",
apply_type: "dynamic",
data_type: "string",
allowed_values: nil,
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
}
]
end
let(:mysql_parameters) do
[
{
parameter_name: "application_name",
parameter_value: nil,
description: "Name of the application",
source: "engine-default",
apply_type: "dynamic",
data_type: "string",
allowed_values: nil,
is_modifiable: true,
minimum_engine_version: nil,
apply_method: nil
},
{
parameter_name: "archive_command",
parameter_value: "/path/to/archive %p",
description: "Command to archive database",
source: "system",
apply_type: "dynamic",
data_type: "string",
allowed_values: nil,
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
}
]
end
let(:pg_parameters) do
[
{
parameter_name: "archive_timeout",
parameter_value: "300",
description: "Timeout seconds for archiving",
source: "system",
apply_type: "dynamic",
data_type: "integer",
allowed_values: "0-214748364",
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
},
{
parameter_name: "array_nulls",
parameter_value: nil,
description: "Enable input of NULL elements",
source: "engine-default",
apply_type: "dynamic",
data_type: "boolean",
allowed_values: "0,1",
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
}
]
end
let(:pg_parameters) do
[
{
parameter_name: "archive_timeout",
parameter_value: "300",
description: "Timeout seconds for archiving",
source: "system",
apply_type: "dynamic",
data_type: "integer",
allowed_values: "0-214748364",
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
},
{
parameter_name: "array_nulls",
parameter_value: nil,
description: "Enable input of NULL elements",
source: "engine-default",
apply_type: "dynamic",
data_type: "boolean",
allowed_values: "0,1",
is_modifiable: false,
minimum_engine_version: nil,
apply_method: nil
}
]
end
before do
client.stub_responses(:describe_db_parameter_groups, db_parameter_groups: db_parameter_groups)
client.stub_responses(:describe_db_parameters, [{ parameters: mysql_parameters }, { parameters: pg_parameters }])
end
before do
client.stub_responses(:describe_db_parameter_groups, db_parameter_groups: db_parameter_groups)
client.stub_responses(:describe_db_parameters, [{ parameters: mysql_parameters }, { parameters: pg_parameters }])
end
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
resource "aws_db_parameter_group" "default-mysql5-6" {
name = "default.mysql5.6"
family = "mysql5.6"
......@@ -126,48 +127,49 @@ resource "aws_db_parameter_group" "default-postgres9-4" {
}
EOS
end
end
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_parameter_group.default-mysql5-6" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.mysql5.6",
"attributes" => {
"description" => "Default parameter group for mysql5.6",
"family" => "mysql5.6",
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_parameter_group.default-mysql5-6" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.mysql5.6",
"name" => "default.mysql5.6",
"parameter.#" => "2",
"attributes" => {
"description" => "Default parameter group for mysql5.6",
"family" => "mysql5.6",
"id" => "default.mysql5.6",
"name" => "default.mysql5.6",
"parameter.#" => "2",
}
}
}
},
"aws_db_parameter_group.default-postgres9-4" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.postgres9.4",
"attributes" => {
"description" => "Default parameter group for postgres9.4",
"family" => "postgres9.4",
},
"aws_db_parameter_group.default-postgres9-4" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.postgres9.4",
"name" => "default.postgres9.4",
"parameter.#" => "2",
"attributes" => {
"description" => "Default parameter group for postgres9.4",
"family" => "postgres9.4",
"id" => "default.postgres9.4",
"name" => "default.postgres9.4",
"parameter.#" => "2",
}
}
}
}
}
}
})
})
end
end
end
end
......
require "spec_helper"
module Terraforming::Resource
describe DBSecurityGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
module Terraforming
module Resource
describe DBSecurityGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
let(:db_security_groups) do
[
{
ip_ranges: [],
owner_id: "123456789012",
db_security_group_description: "default",
ec2_security_groups: [
{
status: "authorized",
ec2_security_group_name: "default",
ec2_security_group_owner_id: "123456789012",
ec2_security_group_id: "sg-1234abcd"
}
],
db_security_group_name: "default"
},
{
ip_ranges: [
{
status: "authorized",
cidrip: "0.0.0.0/0"
}
],
owner_id: "3456789012",
db_security_group_description: "foobar group",
ec2_security_groups: [
{
status: "authorized",
ec2_security_group_name: "foobar",
ec2_security_group_owner_id: "3456789012",
ec2_security_group_id: "sg-5678efgh"
}
],
db_security_group_name: "sgfoobar"
}
]
end
let(:db_security_groups) do
[
{
ip_ranges: [],
owner_id: "123456789012",
db_security_group_description: "default",
ec2_security_groups: [
{
status: "authorized",
ec2_security_group_name: "default",
ec2_security_group_owner_id: "123456789012",
ec2_security_group_id: "sg-1234abcd"
}
],
db_security_group_name: "default"
},
{
ip_ranges: [
{
status: "authorized",
cidrip: "0.0.0.0/0"
}
],
owner_id: "3456789012",
db_security_group_description: "foobar group",
ec2_security_groups: [
{
status: "authorized",
ec2_security_group_name: "foobar",
ec2_security_group_owner_id: "3456789012",
ec2_security_group_id: "sg-5678efgh"
}
],
db_security_group_name: "sgfoobar"
}
]
end
before do
client.stub_responses(:describe_db_security_groups, db_security_groups: db_security_groups)
end
before do
client.stub_responses(:describe_db_security_groups, db_security_groups: db_security_groups)
end
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
resource "aws_db_security_group" "default" {
name = "default"
description = "default"
......@@ -85,47 +86,48 @@ resource "aws_db_security_group" "sgfoobar" {
}
EOS
end
end
end
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_security_group.default" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "default",
"attributes" => {
"db_subnet_group_name" => "default",
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_security_group.default" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "default",
"ingress.#" => "1",
"name" => "default",
"attributes" => {
"db_subnet_group_name" => "default",
"id" => "default",
"ingress.#" => "1",
"name" => "default",
}
}
}
},
"aws_db_security_group.sgfoobar" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "sgfoobar",
"attributes" => {
"db_subnet_group_name" => "sgfoobar",
},
"aws_db_security_group.sgfoobar" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "sgfoobar",
"ingress.#" => "2",
"name" => "sgfoobar",
"attributes" => {
"db_subnet_group_name" => "sgfoobar",
"id" => "sgfoobar",
"ingress.#" => "2",
"name" => "sgfoobar",
}
}
}
}
}
}
})
})
end
end
end
end
......
require "spec_helper"
module Terraforming::Resource
describe DBSubnetGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
module Terraforming
module Resource
describe DBSubnetGroup do
let(:client) do
Aws::RDS::Client.new(stub_responses: true)
end
let(:db_subnet_groups) do
[
{
subnets: [
{
subnet_status: "Active",
subnet_identifier: "subnet-1234abcd",
subnet_availability_zone: {
name: "ap-northeast-1c"
}
},
{
subnet_status: "Active",
subnet_identifier: "subnet-5678efgh",
subnet_availability_zone: {
name: "ap-northeast-1b"
}
}
],
db_subnet_group_name: "hoge",
vpc_id: "vpc-1234abcd",
db_subnet_group_description: "DB subnet group hoge",
subnet_group_status: "Complete"
},
{
subnets: [
{
subnet_status: "Active",
subnet_identifier: "subnet-9012ijkl",
subnet_availability_zone: {
name: "ap-northeast-1b"
let(:db_subnet_groups) do
[
{
subnets: [
{
subnet_status: "Active",
subnet_identifier: "subnet-1234abcd",
subnet_availability_zone: {
name: "ap-northeast-1c"
}
},
{
subnet_status: "Active",
subnet_identifier: "subnet-5678efgh",
subnet_availability_zone: {
name: "ap-northeast-1b"
}
}
},
{
subnet_status: "Active",
subnet_identifier: "subnet-3456mnop",
subnet_availability_zone: {
name: "ap-northeast-1c"
],
db_subnet_group_name: "hoge",
vpc_id: "vpc-1234abcd",
db_subnet_group_description: "DB subnet group hoge",
subnet_group_status: "Complete"
},
{
subnets: [
{
subnet_status: "Active",
subnet_identifier: "subnet-9012ijkl",
subnet_availability_zone: {
name: "ap-northeast-1b"
}
},
{
subnet_status: "Active",
subnet_identifier: "subnet-3456mnop",
subnet_availability_zone: {
name: "ap-northeast-1c"
}
}
}
],
db_subnet_group_name: "fuga",
vpc_id: "vpc-5678efgh",
db_subnet_group_description: "DB subnet group fuga",
subnet_group_status: "Complete"
}
]
end
],
db_subnet_group_name: "fuga",
vpc_id: "vpc-5678efgh",
db_subnet_group_description: "DB subnet group fuga",
subnet_group_status: "Complete"
}
]
end
before do
client.stub_responses(:describe_db_subnet_groups, db_subnet_groups: db_subnet_groups)
end
before do
client.stub_responses(:describe_db_subnet_groups, db_subnet_groups: db_subnet_groups)
end
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client)).to eq <<-EOS
resource "aws_db_subnet_group" "hoge" {
name = "hoge"
description = "DB subnet group hoge"
......@@ -75,45 +76,46 @@ resource "aws_db_subnet_group" "fuga" {
}
EOS
end
end
end
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_subnet_group.hoge" => {
"type" => "aws_db_subnet_group",
"primary" => {
"id" => "hoge",
"attributes" => {
"description" => "DB subnet group hoge",
"name" => "hoge",
"subnet_ids.#" => "2",
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,