Skip to content
Merged
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: 0 additions & 2 deletions lib/brightbox-cli/commands/lbs/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ module Brightbox
c.switch ["sslv3"]

c.action do |global_options, options, args|
raise "You must specify which servers to balance connections to" if args.empty?

listeners = options[:l].split(",").map do |l|
inport, outport, protocol, timeout = l.split ":"
raise "listener '#{l}' is invalid" if inport.nil? || outport.nil? || protocol.nil?
Expand Down
26 changes: 6 additions & 20 deletions spec/commands/lbs/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,22 @@
cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
end

context "without required nodes arguments" do
context "without nodes arguments" do
let(:argv) { %w[lbs create] }

it "does not error" do
expect { output }.to_not raise_error

expect(stderr).to eq("ERROR: You must specify which servers to balance connections to\n")
end
end

context "with required nodes arguments" do
let(:argv) { %w[lbs create srv-12345] }
let(:expected_args) { { nodes: [{ node: "srv-12345" }] } }
let(:expected_args) { { nodes: [] } }

let(:json_response) do
<<~EOS
{
"id": "lba-12345",
"nodes": [
{
"id": "srv-12345"
}
]
"nodes": []
}
EOS
end

before do
stub_request(:post, "http://api.brightbox.localhost/1.0/load_balancers?account_id=acc-12345")
.with(:body => hash_including("nodes" => [{ "node" => "srv-12345" }]))
.with(:body => hash_including("nodes" => []))
.to_return(:status => 202, :body => json_response)
end

Expand All @@ -52,7 +38,7 @@
end
end

context "with required nodes arguments" do
context "with a nodes argument" do
let(:argv) { %w[lbs create srv-12345] }
let(:expected_args) { { nodes: [{ node: "srv-12345" }] } }

Expand Down Expand Up @@ -83,7 +69,7 @@
end
end

context "with multiple nodes" do
context "with multiple node arguments" do
let(:argv) { %w[lbs create srv-12345 srv-54321] }
let(:expected_args) { { nodes: [{ node: "srv-12345" }, { node: "srv-54321" }] } }

Expand Down
Loading