docker-api 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/docker.rb +12 -2
- data/lib/docker/connection.rb +42 -49
- data/lib/docker/container.rb +12 -20
- data/lib/docker/error.rb +3 -0
- data/lib/docker/image.rb +21 -47
- data/lib/docker/model.rb +17 -14
- data/lib/docker/util.rb +12 -0
- data/lib/docker/version.rb +5 -1
- data/spec/docker/connection_spec.rb +56 -30
- data/spec/docker/container_spec.rb +81 -201
- data/spec/docker/image_spec.rb +48 -157
- data/spec/docker/util_spec.rb +43 -0
- data/spec/docker_spec.rb +15 -0
- data/spec/vcr/Docker/_info/returns_the_info_as_a_Hash.yml +10 -8
- data/spec/vcr/Docker/_validate_version/when_nothing_is_raised/validate_version_/.yml +33 -0
- data/spec/vcr/Docker/_version/returns_the_version_as_a_Hash.yml +10 -8
- data/spec/vcr/Docker_Container/_all/when_the_HTTP_response_is_a_200/materializes_each_Container_into_a_Docker_Container.yml +857 -17
- data/spec/vcr/Docker_Container/_attach/{when_the_HTTP_response_status_is_200/yields_each_chunk.yml → yields_each_chunk.yml} +9 -9
- data/spec/vcr/Docker_Container/_changes/{when_the_HTTP_response_status_is_200/returns_the_changes_as_an_array.yml → returns_the_changes_as_an_array.yml} +13 -13
- data/spec/vcr/Docker_Container/_commit/{when_the_HTTP_response_status_is_200/creates_a_new_Image_from_the_Container_s_changes.yml → creates_a_new_Image_from_the_Container_s_changes.yml} +12 -12
- data/spec/vcr/Docker_Container/_create/when_the_Container_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200/sets_the_id.yml +4 -4
- data/spec/vcr/Docker_Container/_export/{when_the_HTTP_response_status_is_200/yields_each_chunk.yml → yields_each_chunk.yml} +11 -11
- data/spec/vcr/Docker_Container/_json/{when_the_HTTP_response_status_is_200/returns_the_description_as_a_Hash.yml → returns_the_description_as_a_Hash.yml} +8 -8
- data/spec/vcr/Docker_Container/_kill/{when_the_HTTP_response_status_is_204/kills_the_container.yml → kills_the_container.yml} +436 -16
- data/spec/vcr/Docker_Container/_restart/{when_the_HTTP_response_status_is_204/restarts_the_container.yml → restarts_the_container.yml} +29 -29
- data/spec/vcr/Docker_Container/_start/{when_the_HTTP_response_status_is_200/starts_the_container.yml → starts_the_container.yml} +12 -12
- data/spec/vcr/Docker_Container/_stop/{when_the_HTTP_response_status_is_204/stops_the_container.yml → stops_the_container.yml} +440 -20
- data/spec/vcr/Docker_Container/_wait/{when_the_HTTP_response_status_is_200/waits_for_the_command_to_finish.yml → waits_for_the_command_to_finish.yml} +10 -10
- data/spec/vcr/Docker_Image/_all/materializes_each_Image_into_a_Docker_Image.yml +65 -0
- data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/builds_an_image.yml +9 -5
- data/spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml +9 -5
- data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/builds_the_image.yml +17 -15
- data/spec/vcr/Docker_Image/{_create_/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200 → _create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash}/sets_the_id.yml +4 -2
- data/spec/vcr/Docker_Image/_history/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/returns_the_history_of_the_Image.yml → returns_the_history_of_the_Image.yml} +7 -5
- data/spec/vcr/Docker_Image/_import/when_the_file_does_exist/creates_the_Image.yml +6 -6
- data/spec/vcr/Docker_Image/_insert/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/inserts_the_url_s_file_into_a_new_Image.yml → inserts_the_url_s_file_into_a_new_Image.yml} +30 -29
- data/spec/vcr/Docker_Image/_json/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/returns_additional_information_about_image_image.yml → returns_additional_information_about_image_image.yml} +7 -5
- data/spec/vcr/Docker_Image/_remove/removes_the_Image.yml +95 -0
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +14 -12
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_an_Array/creates_a_new_Container.yml +14 -12
- data/spec/vcr/Docker_Image/_search/{when_the_HTTP_response_is_a_200/materializes_each_Image_into_a_Docker_Image.yml → materializes_each_Image_into_a_Docker_Image.yml} +4 -34
- data/spec/vcr/Docker_Image/_tag/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/tags_the_image_with_the_repo_name.yml → tags_the_image_with_the_repo_name.yml} +7 -5
- metadata +43 -56
- data/spec/vcr/Docker_Image/_all/when_the_HTTP_response_is_a_200/materializes_each_Image_into_a_Docker_Image.yml +0 -63
- data/spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200/sets_the_id.yml +0 -33
- data/spec/vcr/Docker_Image/_history/when_the_HTTP_response_status_is_200/returns_the_history_of_the_Image.yml +0 -63
- data/spec/vcr/Docker_Image/_insert/when_the_HTTP_response_status_is_200/inserts_the_url_s_file_into_a_new_Image.yml +0 -220
- data/spec/vcr/Docker_Image/_json/when_the_HTTP_response_status_is_200/returns_additional_information_about_image_image.yml +0 -63
- data/spec/vcr/Docker_Image/_remove/when_the_HTTP_response_status_is_204/removes_the_Image.yml +0 -93
- data/spec/vcr/Docker_Image/_remove/when_the_Image_has_been_created/when_the_HTTP_response_status_is_204/nils_out_the_id.yml +0 -63
- data/spec/vcr/Docker_Image/_remove/when_the_Image_has_been_created/when_the_HTTP_response_status_is_204/removes_the_Image.yml +0 -63
- data/spec/vcr/Docker_Image/_run/when_the_Image_has_been_created/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +0 -119
- data/spec/vcr/Docker_Image/_run/when_the_Image_has_been_created/when_the_argument_is_an_Array/creates_a_new_Container.yml +0 -119
- data/spec/vcr/Docker_Image/_tag/when_the_HTTP_response_status_is_200/tags_the_image_with_the_repo_name.yml +0 -63
@@ -3,11 +3,11 @@ require 'spec_helper'
|
|
3
3
|
# WARNING if you're re-recording any of these VCRs, you must be running the
|
4
4
|
# Docker daemon and have the base Image pulled.
|
5
5
|
describe Docker::Container do
|
6
|
-
subject { described_class.send(:new, :id => rand(10000).to_s) }
|
7
|
-
|
8
6
|
describe '#to_s' do
|
7
|
+
subject { described_class.send(:new, :id => rand(10000).to_s) }
|
8
|
+
|
9
9
|
let(:id) { 'bf119e2' }
|
10
|
-
let(:connection) { Docker
|
10
|
+
let(:connection) { Docker.connection }
|
11
11
|
let(:expected_string) {
|
12
12
|
"Docker::Container { :id => #{id}, :connection => #{connection} }"
|
13
13
|
}
|
@@ -22,259 +22,139 @@ describe Docker::Container do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#json' do
|
25
|
-
|
26
|
-
|
27
|
-
after { Excon.stubs.shift }
|
25
|
+
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
26
|
+
let(:description) { subject.json }
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when the HTTP response status is 200' do
|
36
|
-
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
37
|
-
let(:description) { subject.json }
|
38
|
-
|
39
|
-
it 'returns the description as a Hash', :vcr do
|
40
|
-
description.should be_a(Hash)
|
41
|
-
description['ID'].should start_with(subject.id)
|
42
|
-
end
|
28
|
+
it 'returns the description as a Hash', :vcr do
|
29
|
+
description.should be_a(Hash)
|
30
|
+
description['ID'].should start_with(subject.id)
|
43
31
|
end
|
44
32
|
end
|
45
33
|
|
46
34
|
describe '#changes' do
|
47
|
-
|
48
|
-
|
49
|
-
after { Excon.stubs.shift }
|
35
|
+
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
36
|
+
let(:changes) { subject.changes }
|
50
37
|
|
51
|
-
|
52
|
-
expect { subject.changes }
|
53
|
-
.to raise_error(Docker::Error::ServerError)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'when the HTTP response status is 200' do
|
58
|
-
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
59
|
-
let(:changes) { subject.changes }
|
60
|
-
|
61
|
-
before { subject.tap(&:start).tap(&:wait) }
|
38
|
+
before { subject.tap(&:start).tap(&:wait) }
|
62
39
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
40
|
+
it 'returns the changes as an array', :vcr do
|
41
|
+
changes.should be_a Array
|
42
|
+
changes.should be_all { |change| change.is_a?(Hash) }
|
43
|
+
changes.length.should_not be_zero
|
68
44
|
end
|
69
45
|
end
|
70
46
|
|
71
47
|
describe '#export' do
|
72
|
-
|
73
|
-
|
74
|
-
|
48
|
+
subject { described_class.create('Cmd' => %w[rm -rf / --no-preserve-root],
|
49
|
+
'Image' => 'base') }
|
50
|
+
before { subject.start }
|
75
51
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
Docker::Container.create('Cmd' => %w[rm -rf / --no-preserve-root],
|
85
|
-
'Image' => 'base')
|
86
|
-
}
|
87
|
-
before { subject.start }
|
88
|
-
|
89
|
-
it 'yields each chunk', :vcr do
|
90
|
-
first = nil
|
91
|
-
subject.export do |chunk|
|
92
|
-
first = chunk
|
93
|
-
break
|
94
|
-
end
|
95
|
-
first[257..261].should == "ustar" # Make sure the export is a tar.
|
52
|
+
# If you have to re-record this VCR, PLEASE edit it so that it's only ~200
|
53
|
+
# lines. This is only because we don't want our gem to be a few hundred
|
54
|
+
# megabytes.
|
55
|
+
it 'yields each chunk', :vcr do
|
56
|
+
first = nil
|
57
|
+
subject.export do |chunk|
|
58
|
+
first = chunk
|
59
|
+
break
|
96
60
|
end
|
61
|
+
first[257..261].should == "ustar" # Make sure the export is a tar.
|
97
62
|
end
|
98
63
|
end
|
99
64
|
|
100
65
|
describe '#attach' do
|
101
|
-
|
102
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
103
|
-
after { Excon.stubs.shift }
|
66
|
+
subject { described_class.create('Cmd' => %w[uname -r], 'Image' => 'base') }
|
104
67
|
|
105
|
-
|
106
|
-
expect { subject.attach { } }
|
107
|
-
.to raise_error(Docker::Error::ServerError)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when the HTTP response status is 200' do
|
112
|
-
subject { described_class.create('Cmd' => %w[uname -r],
|
113
|
-
'Image' => 'base') }
|
68
|
+
before { subject.start }
|
114
69
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
70
|
+
it 'yields each chunk', :vcr do
|
71
|
+
subject.attach { |chunk|
|
72
|
+
chunk.should == "3.8.0-25-generic\n"
|
73
|
+
break
|
74
|
+
}
|
120
75
|
end
|
121
76
|
end
|
122
77
|
|
123
78
|
describe '#start' do
|
124
|
-
|
125
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
126
|
-
after { Excon.stubs.shift }
|
127
|
-
|
128
|
-
it 'raises an error' do
|
129
|
-
expect { subject.start }
|
130
|
-
.to raise_error(Docker::Error::ServerError)
|
131
|
-
end
|
132
|
-
end
|
79
|
+
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
133
80
|
|
134
|
-
|
135
|
-
subject
|
136
|
-
|
81
|
+
it 'starts the container', :vcr do
|
82
|
+
subject.start
|
83
|
+
described_class.all.map(&:id).should be_any { |id|
|
84
|
+
id.start_with?(subject.id)
|
137
85
|
}
|
138
|
-
|
139
|
-
it 'starts the container', :vcr do
|
140
|
-
subject.start
|
141
|
-
described_class.all.map(&:id).should be_any { |id|
|
142
|
-
id.start_with?(subject.id)
|
143
|
-
}
|
144
|
-
end
|
145
86
|
end
|
146
87
|
end
|
147
88
|
|
148
89
|
describe '#stop' do
|
149
|
-
|
150
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
151
|
-
after { Excon.stubs.shift }
|
90
|
+
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
152
91
|
|
153
|
-
|
154
|
-
expect { subject.stop }
|
155
|
-
.to raise_error(Docker::Error::ServerError)
|
156
|
-
end
|
157
|
-
end
|
92
|
+
before { subject.tap(&:start).stop }
|
158
93
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
}
|
167
|
-
described_class.all.map(&:id).should be_none { |id|
|
168
|
-
id.start_with?(subject.id)
|
169
|
-
}
|
170
|
-
end
|
94
|
+
it 'stops the container', :vcr do
|
95
|
+
described_class.all(:all => true).map(&:id).should be_any { |id|
|
96
|
+
id.start_with?(subject.id)
|
97
|
+
}
|
98
|
+
described_class.all.map(&:id).should be_none { |id|
|
99
|
+
id.start_with?(subject.id)
|
100
|
+
}
|
171
101
|
end
|
172
102
|
end
|
173
103
|
|
174
104
|
describe '#kill' do
|
175
|
-
|
176
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
177
|
-
after { Excon.stubs.shift }
|
105
|
+
subject { described_class.create('Cmd' => ['ls'], 'Image' => 'base') }
|
178
106
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
it 'kills the container', :vcr do
|
189
|
-
subject.kill
|
190
|
-
described_class.all.map(&:id).should be_none { |id|
|
191
|
-
id.start_with?(subject.id)
|
192
|
-
}
|
193
|
-
described_class.all(:all => true).map(&:id).should be_any { |id|
|
194
|
-
id.start_with?(subject.id)
|
195
|
-
}
|
196
|
-
end
|
107
|
+
it 'kills the container', :vcr do
|
108
|
+
subject.kill
|
109
|
+
described_class.all.map(&:id).should be_none { |id|
|
110
|
+
id.start_with?(subject.id)
|
111
|
+
}
|
112
|
+
described_class.all(:all => true).map(&:id).should be_any { |id|
|
113
|
+
id.start_with?(subject.id)
|
114
|
+
}
|
197
115
|
end
|
198
116
|
end
|
199
117
|
|
200
118
|
describe '#restart' do
|
201
|
-
|
202
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
203
|
-
after { Excon.stubs.shift }
|
119
|
+
subject { described_class.create('Cmd' => %w[sleep 50], 'Image' => 'base') }
|
204
120
|
|
205
|
-
|
206
|
-
expect { subject.restart }
|
207
|
-
.to raise_error(Docker::Error::ServerError)
|
208
|
-
end
|
209
|
-
end
|
121
|
+
before { subject.start }
|
210
122
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
123
|
+
it 'restarts the container', :vcr do
|
124
|
+
described_class.all.map(&:id).should be_any { |id|
|
125
|
+
id.start_with?(subject.id)
|
126
|
+
}
|
127
|
+
subject.stop
|
128
|
+
described_class.all.map(&:id).should be_none { |id|
|
129
|
+
id.start_with?(subject.id)
|
130
|
+
}
|
131
|
+
subject.restart
|
132
|
+
described_class.all.map(&:id).should be_any { |id|
|
133
|
+
id.start_with?(subject.id)
|
215
134
|
}
|
216
|
-
|
217
|
-
it 'restarts the container', :vcr do
|
218
|
-
subject.start
|
219
|
-
described_class.all.map(&:id).should be_any { |id|
|
220
|
-
id.start_with?(subject.id)
|
221
|
-
}
|
222
|
-
subject.stop
|
223
|
-
described_class.all.map(&:id).should be_none { |id|
|
224
|
-
id.start_with?(subject.id)
|
225
|
-
}
|
226
|
-
subject.restart
|
227
|
-
described_class.all.map(&:id).should be_any { |id|
|
228
|
-
id.start_with?(subject.id)
|
229
|
-
}
|
230
|
-
end
|
231
135
|
end
|
232
136
|
end
|
233
137
|
|
234
138
|
describe '#wait' do
|
235
|
-
|
236
|
-
|
237
|
-
after { Excon.stubs.shift }
|
238
|
-
|
239
|
-
it 'raises an error' do
|
240
|
-
expect { subject.wait }
|
241
|
-
.to raise_error(Docker::Error::ServerError)
|
242
|
-
end
|
243
|
-
end
|
139
|
+
subject { described_class.create('Cmd' => %w[tar nonsense],
|
140
|
+
'Image' => 'base') }
|
244
141
|
|
245
|
-
|
246
|
-
subject {
|
247
|
-
described_class.create('Cmd' => %w[tar nonsense],
|
248
|
-
'Image' => 'base') }
|
142
|
+
before { subject.start }
|
249
143
|
|
250
|
-
|
251
|
-
|
252
|
-
subject.wait['StatusCode'].should == 64
|
253
|
-
end
|
144
|
+
it 'waits for the command to finish', :vcr do
|
145
|
+
subject.wait['StatusCode'].should == 64
|
254
146
|
end
|
255
147
|
end
|
256
148
|
|
257
149
|
describe '#commit' do
|
258
|
-
|
259
|
-
|
260
|
-
after { Excon.stubs.shift }
|
261
|
-
|
262
|
-
it 'raises an error' do
|
263
|
-
expect { subject.commit }
|
264
|
-
.to raise_error(Docker::Error::ServerError)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
context 'when the HTTP response status is 200' do
|
269
|
-
let(:image) { subject.commit }
|
270
|
-
subject { described_class.create('Cmd' => %w[ls], 'Image' => 'base') }
|
150
|
+
subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
|
151
|
+
let(:image) { subject.commit }
|
271
152
|
|
272
|
-
|
153
|
+
before { subject.start }
|
273
154
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
end
|
155
|
+
it 'creates a new Image from the Container\'s changes', :vcr do
|
156
|
+
image.should be_a Docker::Image
|
157
|
+
image.id.should_not be_nil
|
278
158
|
end
|
279
159
|
end
|
280
160
|
|
data/spec/docker/image_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Docker::Image do
|
4
|
-
subject { described_class.send(:new, :id => rand(10000).to_s) }
|
5
|
-
|
6
4
|
describe '#to_s' do
|
5
|
+
subject { described_class.send(:new, :id => rand(10000).to_s) }
|
6
|
+
|
7
7
|
let(:id) { 'bf119e2' }
|
8
|
-
let(:connection) { Docker
|
8
|
+
let(:connection) { Docker.connection }
|
9
9
|
let(:expected_string) do
|
10
10
|
"Docker::Image { :id => #{id}, :connection => #{connection} }"
|
11
11
|
end
|
@@ -20,137 +20,62 @@ describe Docker::Image do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#remove' do
|
23
|
-
|
24
|
-
|
25
|
-
after { Excon.stubs.shift }
|
23
|
+
let(:id) { subject.id }
|
24
|
+
subject { described_class.create('fromImage' => 'base') }
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when the HTTP response status is 204' do
|
34
|
-
let(:id) { subject.id }
|
35
|
-
subject { described_class.create('fromImage' => 'base') }
|
36
|
-
|
37
|
-
it 'removes the Image', :vcr do
|
38
|
-
subject.remove
|
39
|
-
Docker::Image.all.map(&:id).should_not include(id)
|
40
|
-
end
|
26
|
+
it 'removes the Image', :vcr do
|
27
|
+
subject.remove
|
28
|
+
Docker::Image.all.map(&:id).should_not include(id)
|
41
29
|
end
|
42
30
|
end
|
43
31
|
|
44
32
|
describe '#insert' do
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
subject { described_class.build('from base') }
|
34
|
+
let(:new_image) { subject.insert(:path => '/stallman',
|
35
|
+
:url => 'http://stallman.org') }
|
36
|
+
let(:ls_output) { new_image.run('ls /').attach.split("\n") }
|
48
37
|
|
49
|
-
|
50
|
-
|
51
|
-
.to raise_error(Docker::Error::ServerError)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when the HTTP response status is 200' do
|
56
|
-
subject { described_class.build('from base') }
|
57
|
-
let(:new_image) { subject.insert(:path => '/stallman',
|
58
|
-
:url => 'http://stallman.org') }
|
59
|
-
let(:ls_output) { new_image.run('ls /').attach.split("\n") }
|
60
|
-
|
61
|
-
it 'inserts the url\'s file into a new Image', :vcr do
|
62
|
-
ls_output.should include('stallman')
|
63
|
-
end
|
38
|
+
it 'inserts the url\'s file into a new Image', :vcr do
|
39
|
+
ls_output.should include('stallman')
|
64
40
|
end
|
65
41
|
end
|
66
42
|
|
67
43
|
describe '#push' do
|
68
|
-
|
69
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
70
|
-
after { Excon.stubs.shift }
|
71
|
-
|
72
|
-
it 'raises an error' do
|
73
|
-
expect { subject.push }
|
74
|
-
.to raise_error(Docker::Error::ServerError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when the HTTP response status is 200' do
|
79
|
-
subject { described_class.create('fromImage' => 'base') }
|
44
|
+
subject { described_class.create('fromImage' => 'base') }
|
80
45
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
46
|
+
it 'pushes the Image', :vcr do
|
47
|
+
pending 'I don\'t want to push the Image to the Docker Registry'
|
48
|
+
subject.push
|
85
49
|
end
|
86
50
|
end
|
87
51
|
|
88
52
|
describe '#tag' do
|
89
|
-
|
90
|
-
before { Excon.stub({ :method => :post }, { :status => 500 }) }
|
91
|
-
after { Excon.stubs.shift }
|
92
|
-
|
93
|
-
it 'raises an error' do
|
94
|
-
expect { subject.tag }
|
95
|
-
.to raise_error(Docker::Error::ServerError)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'when the HTTP response status is 200' do
|
100
|
-
subject { described_class.create('fromImage' => 'base') }
|
53
|
+
subject { described_class.create('fromImage' => 'base') }
|
101
54
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
55
|
+
it 'tags the image with the repo name', :vcr do
|
56
|
+
expect { subject.tag(:repo => 'base2', :force => true) }
|
57
|
+
.to_not raise_error
|
106
58
|
end
|
107
59
|
end
|
108
60
|
|
109
61
|
describe '#json' do
|
110
|
-
|
111
|
-
|
112
|
-
subject.stub(:created?).and_return(true)
|
113
|
-
Excon.stub({ :method => :get }, { :status => 500 })
|
114
|
-
end
|
115
|
-
after { Excon.stubs.shift }
|
116
|
-
|
117
|
-
it 'raises an error' do
|
118
|
-
expect { subject.json }
|
119
|
-
.to raise_error(Docker::Error::ServerError)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'when the HTTP response status is 200' do
|
124
|
-
subject { described_class.create('fromImage' => 'base') }
|
125
|
-
let(:json) { subject.json }
|
62
|
+
subject { described_class.create('fromImage' => 'base') }
|
63
|
+
let(:json) { subject.json }
|
126
64
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
65
|
+
it 'returns additional information about image image', :vcr do
|
66
|
+
json.should be_a Hash
|
67
|
+
json.length.should_not be_zero
|
131
68
|
end
|
132
69
|
end
|
133
70
|
|
134
71
|
describe '#history' do
|
135
|
-
|
136
|
-
|
137
|
-
after { Excon.stubs.shift }
|
138
|
-
|
139
|
-
it 'raises an error' do
|
140
|
-
expect { subject.history }
|
141
|
-
.to raise_error(Docker::Error::ServerError)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'when the HTTP response status is 200' do
|
146
|
-
subject { described_class.create('fromImage' => 'base') }
|
147
|
-
let(:history) { subject.history }
|
72
|
+
subject { described_class.create('fromImage' => 'base') }
|
73
|
+
let(:history) { subject.history }
|
148
74
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
75
|
+
it 'returns the history of the Image', :vcr do
|
76
|
+
history.should be_a Array
|
77
|
+
history.length.should_not be_zero
|
78
|
+
history.should be_all { |elem| elem.is_a? Hash }
|
154
79
|
end
|
155
80
|
end
|
156
81
|
|
@@ -185,21 +110,11 @@ describe Docker::Image do
|
|
185
110
|
end
|
186
111
|
|
187
112
|
context 'when the Image does not yet exist and the body is a Hash' do
|
188
|
-
|
189
|
-
before { Excon.stub({ :method => :post }, { :status => 400 }) }
|
190
|
-
after { Excon.stubs.shift }
|
191
|
-
|
192
|
-
it 'raises an error' do
|
193
|
-
expect { subject.create }.to raise_error(Docker::Error::ClientError)
|
194
|
-
end
|
195
|
-
end
|
113
|
+
let(:image) { subject.create('fromImage' => 'base') }
|
196
114
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
image.should be_a Docker::Image
|
201
|
-
image.id.should_not be_nil
|
202
|
-
end
|
115
|
+
it 'sets the id', :vcr do
|
116
|
+
image.should be_a Docker::Image
|
117
|
+
image.id.should_not be_nil
|
203
118
|
end
|
204
119
|
end
|
205
120
|
end
|
@@ -235,48 +150,24 @@ describe Docker::Image do
|
|
235
150
|
describe '.all' do
|
236
151
|
subject { described_class }
|
237
152
|
|
238
|
-
|
239
|
-
|
240
|
-
after { Excon.stubs.shift }
|
153
|
+
let(:images) { subject.all(:all => true) }
|
154
|
+
before { subject.create('fromImage' => 'base') }
|
241
155
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
context 'when the HTTP response is a 200' do
|
249
|
-
let(:images) { subject.all(:all => true) }
|
250
|
-
before { subject.create('fromImage' => 'base') }
|
251
|
-
|
252
|
-
it 'materializes each Image into a Docker::Image', :vcr do
|
253
|
-
images.should be_all { |image|
|
254
|
-
!image.id.nil? && image.is_a?(described_class)
|
255
|
-
}
|
256
|
-
images.length.should_not be_zero
|
257
|
-
end
|
156
|
+
it 'materializes each Image into a Docker::Image', :vcr do
|
157
|
+
images.should be_all { |image|
|
158
|
+
!image.id.nil? && image.is_a?(described_class)
|
159
|
+
}
|
160
|
+
images.length.should_not be_zero
|
258
161
|
end
|
259
162
|
end
|
260
163
|
|
261
164
|
describe '.search' do
|
262
165
|
subject { described_class }
|
263
166
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
it 'raises an error' do
|
269
|
-
expect { subject.search }
|
270
|
-
.to raise_error(Docker::Error::ServerError)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
context 'when the HTTP response is a 200' do
|
275
|
-
it 'materializes each Image into a Docker::Image', :vcr do
|
276
|
-
subject.search('term' => 'sshd').should be_all { |image|
|
277
|
-
!image.id.nil? && image.is_a?(described_class)
|
278
|
-
}
|
279
|
-
end
|
167
|
+
it 'materializes each Image into a Docker::Image', :vcr do
|
168
|
+
subject.search('term' => 'sshd').should be_all { |image|
|
169
|
+
!image.id.nil? && image.is_a?(described_class)
|
170
|
+
}
|
280
171
|
end
|
281
172
|
end
|
282
173
|
|