Class: EY::SnapshotMinder::Backend::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/ey-flex/snapshot_minder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMock

Returns a new instance of Mock.



7
8
9
10
11
# File 'lib/ey-flex/snapshot_minder.rb', line 7

def initialize
  @commands_called = []
  @raise_count = 0
  @total_wait_time = 0
end

Instance Attribute Details

#commands_calledObject (readonly)

Returns the value of attribute commands_called.



13
14
15
# File 'lib/ey-flex/snapshot_minder.rb', line 13

def commands_called
  @commands_called
end

#raise_countObject

Returns the value of attribute raise_count.



14
15
16
# File 'lib/ey-flex/snapshot_minder.rb', line 14

def raise_count
  @raise_count
end

#total_wait_timeObject (readonly)

Returns the value of attribute total_wait_time.



13
14
15
# File 'lib/ey-flex/snapshot_minder.rb', line 13

def total_wait_time
  @total_wait_time
end

Instance Method Details

#listObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/ey-flex/snapshot_minder.rb', line 29

def list
  @commands_called << "list_snapshots"
  [EY::InstanceAPIClient::Snapshot.new({
    'state' => 'in progress',
    'progress' => '0%',
    'volume_type' => 'db',
    'snapshot_id' => 12,
    'created_at' => Time.now.to_s
    })]
end

#snapshotObject



20
21
22
23
24
25
26
27
# File 'lib/ey-flex/snapshot_minder.rb', line 20

def snapshot
  if @raise_count > 0
    @raise_count -= 1
    raise EY::InstanceAPIClient::Connection::UnexpectedStatus.new("")
  else
    @commands_called << "request_snapshot"
  end
end

#wait(seconds) ⇒ Object



16
17
18
# File 'lib/ey-flex/snapshot_minder.rb', line 16

def wait(seconds)
  @total_wait_time += seconds
end