Skip to content

Commit

Permalink
Use create_XXXX! methods
Browse files Browse the repository at this point in the history
View aptible/aptible-resource#30 for
rationale.
  • Loading branch information
krallin committed Jun 15, 2016
1 parent 4707938 commit b241a8d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/aptible/cli/helpers/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def present_environment_databases(environment)
end

def clone_database(source, dest_handle)
op = source.create_operation(type: 'clone', handle: dest_handle)
op = source.create_operation!(type: 'clone', handle: dest_handle)
poll_for_success(op)

databases_from_handle(dest_handle, source.account).first
Expand Down
6 changes: 3 additions & 3 deletions lib/aptible/cli/subcommands/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def apps
"exist for app #{app.handle}. Valid " \
"types: #{valid_types}."
end
op = service.create_operation(type: 'scale',
container_count: num,
container_size: options[:size])
op = service.create_operation!(type: 'scale',
container_count: num,
container_size: options[:size])
attach_to_operation_logs(op)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/aptible/cli/subcommands/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def config
# FIXME: define_method - ?! Seriously, WTF Thor.
app = ensure_app(options)
env = Hash[args.map { |arg| arg.split('=', 2) }]
operation = app.create_operation(type: 'configure', env: env)
operation = app.create_operation!(type: 'configure', env: env)
puts 'Updating configuration and restarting app...'
attach_to_operation_logs(operation)
end
Expand All @@ -41,7 +41,7 @@ def config
# FIXME: define_method - ?! Seriously, WTF Thor.
app = ensure_app(options)
env = Hash[args.map { |arg| [arg, ''] }]
operation = app.create_operation(type: 'configure', env: env)
operation = app.create_operation!(type: 'configure', env: env)
puts 'Updating configuration and restarting app...'
attach_to_operation_logs(operation)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/aptible/cli/subcommands/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def self.included(thor)
if database.errors.any?
fail Thor::Error, database.errors.full_messages.first
else
op = database.create_operation(type: 'provision',
disk_size: options[:size])
op = database.create_operation!(type: 'provision',
disk_size: options[:size])
attach_to_operation_logs(op)
say database.reload.connection_url
end
Expand Down
2 changes: 1 addition & 1 deletion lib/aptible/cli/subcommands/rebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.included(thor)
app_options
def rebuild
app = ensure_app(options)
operation = app.create_operation(type: 'rebuild')
operation = app.create_operation!(type: 'rebuild')
puts 'Rebuilding app...'
attach_to_operation_logs(operation)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/aptible/cli/subcommands/restart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.included(thor)
app_options
def restart
app = ensure_app(options)
operation = app.create_operation(type: 'restart')
operation = app.create_operation!(type: 'restart')
puts 'Restarting app...'
attach_to_operation_logs(operation)
end
Expand Down
10 changes: 5 additions & 5 deletions spec/aptible/cli/subcommands/apps_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Account < OpenStruct

describe '#apps:scale' do
it 'should pass given correct parameters' do
allow(service).to receive(:create_operation) { op }
allow(service).to receive(:create_operation!) { op }
allow(subject).to receive(:options) do
{ app: 'hello', environment: 'foobar' }
end
Expand All @@ -48,7 +48,7 @@ class Account < OpenStruct
end

it 'should pass container size param to operation if given' do
expect(service).to receive(:create_operation)
expect(service).to receive(:create_operation!)
.with(type: 'scale', container_count: 3, container_size: 90210)
.and_return(op)
allow(subject).to receive(:options) do
Expand All @@ -69,7 +69,7 @@ class Account < OpenStruct
allow(subject).to receive(:options) do
{ environment: 'foo', app: 'web' }
end
allow(service).to receive(:create_operation) { op }
allow(service).to receive(:create_operation!) { op }
allow(Aptible::Api::Account).to receive(:all) { [] }
allow(account).to receive(:apps) { [apps] }

Expand All @@ -79,7 +79,7 @@ class Account < OpenStruct
end

it 'should fail if app is non-existent' do
allow(service).to receive(:create_operation) { op }
allow(service).to receive(:create_operation!) { op }
allow(Aptible::Api::Account).to receive(:all) { [account] }
allow(account).to receive(:apps) { [] }

Expand All @@ -89,7 +89,7 @@ class Account < OpenStruct
end

it 'should fail if number is not a valid number' do
allow(service).to receive(:create_operation) { op }
allow(service).to receive(:create_operation!) { op }
allow(subject).to receive(:options) { { app: 'hello' } }
allow(Aptible::Api::App).to receive(:all) { apps }

Expand Down

0 comments on commit b241a8d

Please sign in to comment.