Skip to content

Commit bb26290

Browse files
committed
Fail with shutdown error only if this option is enabled.
1 parent 08bc444 commit bb26290

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/do_snapshot/command.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@ def stop_droplet(droplet)
5555
false
5656
end
5757

58+
def fail_if_shutdown(droplet)
59+
return unless shutdown
60+
fail DropletPowerError.new(droplet.id), droplet.name unless api.inactive?(droplet.id)
61+
end
62+
5863
# Trying to create a snapshot.
5964
#
6065
def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize
61-
fail DropletPowerError.new(droplet.id), droplet.name unless api.inactive?(droplet.id)
66+
fail_if_shutdown(droplet)
6267

6368
logger.info "Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}."
6469

spec/do_snapshot/command_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
load_options(shutdown: false)
203203
droplet = cmd.api.droplet droplet_id
204204
cmd.create_snapshot(droplet)
205+
expect(DoSnapshot.logger.buffer)
206+
.not_to include "Droplet id: #{droplet_id} must be Powered Off!"
205207
expect { cmd.create_snapshot(droplet) }
206208
.not_to raise_error
207209
end

0 commit comments

Comments
 (0)