Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/aws_agcod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module AGCOD
def self.configure(&block)
@config = Config.new
@config ||= Config.new

yield @config

Expand Down
15 changes: 11 additions & 4 deletions lib/aws_agcod/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ class Config
:production

URI = {
sandbox: "https://agcod-v2-gamma.amazon.com",
production: "https://agcod-v2.amazon.com"
sandbox: {
"us-east-1" => "https://agcod-v2-gamma.amazon.com",
"eu-west-1" => "https://agcod-v2-eu-gamma.amazon.com",
"us-west-2" => "https://agcod-v2-fe-gamma.amazon.com"
},
production: {
"us-east-1" => "https://agcod-v2.amazon.com",
"eu-west-1" => "https://agcod-v2-eu.amazon.com",
"us-west-2" => "https://agcod-v2-fe.amazon.com"
}
}

def initialize
Expand All @@ -22,8 +30,7 @@ def initialize

def uri
return @uri if @uri

production ? URI[:production] : URI[:sandbox]
production ? URI[:production][@region] : URI[:sandbox][@region]
end
end
end
40 changes: 32 additions & 8 deletions spec/aws_agcod/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,43 @@
end

context "when uri is not set" do
context "when production is enabled" do
before do
config.production = true
context "with default region" do
context "when production is enabled" do
before do
config.production = true
end

it "returns the us-east-1 production uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:production]["us-east-1"])
end
end

it "returns the production uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:production])
context "when production is disabled" do
it "returns the us-east-1 sandbox uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:sandbox]["us-east-1"])
end
end
end

context "when production is disabled" do
it "returns the sandbox uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:sandbox])
context "with specified region" do
before do
config.region = "eu-west-1"
end

context "when production is enabled" do
before do
config.production = true
end

it "returns the specified production uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:production]["eu-west-1"])
end
end

context "when production is disabled" do
it "returns the us-east-1 sandbox uri" do
expect(config.uri).to eq(AGCOD::Config::URI[:sandbox]["eu-west-1"])
end
end
end
end
Expand Down