mulder 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mulder/client.rb +1 -1
- data/lib/mulder/instance.rb +5 -1
- data/lib/mulder/version.rb +1 -1
- data/spec/lib/mulder/client_spec.rb +28 -2
- data/spec/lib/mulder/instance_spec.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a53034a0cb8244e38367c1cc27b3eb0f17e6716
|
4
|
+
data.tar.gz: b88ceb563a7839f4ea91542fc4a90a1f99c19438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62cde3c1e60be2a0841a6c81ab35fda37d72402fd00b5b13bc294d6408b28b7181736a87440a666e4d5a9820a6d8e714c91166760d95251f983f143a2da72fdf
|
7
|
+
data.tar.gz: 66adbf8dba59c6a7de266643055da51556f1ceff84dc82d7eead75d6f038c1afdcc63c45adf691d5ba6253f5a94f9c9fbc2bb4557ef0c1b7d63600a59a3814e7
|
data/lib/mulder/client.rb
CHANGED
data/lib/mulder/instance.rb
CHANGED
@@ -37,6 +37,10 @@ module Mulder
|
|
37
37
|
@fog_compute_instance.created_at
|
38
38
|
end
|
39
39
|
|
40
|
+
def exists?
|
41
|
+
!@fog_compute_instance.nil?
|
42
|
+
end
|
43
|
+
|
40
44
|
def as_hash
|
41
45
|
@as_hash ||= {
|
42
46
|
id: id,
|
@@ -49,4 +53,4 @@ module Mulder
|
|
49
53
|
}.delete_if { |_, value| value == '' || value == nil }
|
50
54
|
end
|
51
55
|
end
|
52
|
-
end
|
56
|
+
end
|
data/lib/mulder/version.rb
CHANGED
@@ -25,10 +25,36 @@ describe Mulder::Client do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#instances' do
|
28
|
+
let(:mocked_connection) { mock }
|
29
|
+
let(:mocked_group) { mock }
|
30
|
+
let(:client) { described_class.new(mocked_connection, 'foo', 'bar', 'worker') }
|
31
|
+
let(:instances) { [] }
|
32
|
+
|
33
|
+
before do
|
34
|
+
mocked_connection.stubs(:instances_by_group).with(mocked_group).returns(instances)
|
35
|
+
client.stubs(:group).returns(mocked_group)
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when there are no unhealthy instances' do
|
39
|
+
let(:instances) {[mock('healthy instance', exists?: true), mock('healthy instance', exists?: true)]}
|
40
|
+
|
41
|
+
it 'returns all instances' do
|
42
|
+
client.instances.size.should == 2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when there are unhealthy instances' do
|
47
|
+
let(:instances) { [mock('healthy instance', exists?: true), mock('unhealthy instance', exists?: false)] }
|
48
|
+
|
49
|
+
it 'returns only the healthy ones' do
|
50
|
+
client.instances.size.should == 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
28
54
|
it 'finds the instances for the group' do
|
29
55
|
mocked_connection = mock
|
30
56
|
mocked_group = mock
|
31
|
-
mocked_connection.expects(:instances_by_group).with(mocked_group)
|
57
|
+
mocked_connection.expects(:instances_by_group).with(mocked_group).returns([])
|
32
58
|
client = described_class.new(mocked_connection, 'foo', 'bar', 'worker')
|
33
59
|
client.expects(:group).returns(mocked_group)
|
34
60
|
|
@@ -72,4 +98,4 @@ describe Mulder::Client do
|
|
72
98
|
end
|
73
99
|
end
|
74
100
|
|
75
|
-
end
|
101
|
+
end
|
@@ -11,6 +11,21 @@ describe Mulder::Instance do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
describe '#exists?' do
|
15
|
+
context 'when there is a compute instance' do
|
16
|
+
it 'returns true' do
|
17
|
+
fog_compute_instance = mock
|
18
|
+
described_class.new(fog_compute_instance).should exist
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when there no compute instance' do
|
23
|
+
it 'returns false' do
|
24
|
+
described_class.new(nil).should_not exist
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
14
29
|
describe '#as_hash' do
|
15
30
|
let(:instance) { mock(attributes) }
|
16
31
|
|
@@ -31,4 +46,4 @@ describe Mulder::Instance do
|
|
31
46
|
end
|
32
47
|
end
|
33
48
|
|
34
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mulder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Grazier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|