heirloom 0.6.1 → 0.7.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -1
- data/lib/heirloom/acl/s3.rb +1 -1
- data/lib/heirloom/archive/authorizer.rb +1 -1
- data/lib/heirloom/archive/builder.rb +1 -3
- data/lib/heirloom/archive/destroyer.rb +2 -19
- data/lib/heirloom/archive/lister.rb +1 -1
- data/lib/heirloom/archive/reader.rb +1 -1
- data/lib/heirloom/archive/teardowner.rb +48 -0
- data/lib/heirloom/archive/verifier.rb +2 -2
- data/lib/heirloom/archive.rb +16 -3
- data/lib/heirloom/aws/s3.rb +8 -4
- data/lib/heirloom/aws/simpledb.rb +6 -1
- data/lib/heirloom/catalog/add.rb +31 -0
- data/lib/heirloom/catalog/delete.rb +37 -0
- data/lib/heirloom/catalog/list.rb +22 -0
- data/lib/heirloom/catalog/setup.rb +30 -0
- data/lib/heirloom/catalog/show.rb +35 -0
- data/lib/heirloom/catalog/verify.rb +39 -0
- data/lib/heirloom/catalog.rb +65 -0
- data/lib/heirloom/cli/authorize.rb +4 -4
- data/lib/heirloom/cli/catalog.rb +62 -0
- data/lib/heirloom/cli/destroy.rb +4 -4
- data/lib/heirloom/cli/download.rb +24 -13
- data/lib/heirloom/cli/list.rb +2 -2
- data/lib/heirloom/cli/setup.rb +21 -6
- data/lib/heirloom/cli/shared.rb +12 -3
- data/lib/heirloom/cli/show.rb +3 -3
- data/lib/heirloom/cli/tag.rb +3 -3
- data/lib/heirloom/cli/teardown.rb +75 -0
- data/lib/heirloom/cli/upload.rb +17 -26
- data/lib/heirloom/cli.rb +7 -1
- data/lib/heirloom/directory/directory.rb +1 -1
- data/lib/heirloom/version.rb +1 -1
- data/lib/heirloom.rb +7 -6
- data/spec/acl/s3_spec.rb +2 -7
- data/spec/archive/destroyer_spec.rb +4 -17
- data/spec/archive/lister_spec.rb +1 -1
- data/spec/archive/reader_spec.rb +9 -9
- data/spec/archive/teardowner_spec.rb +42 -0
- data/spec/archive_spec.rb +23 -3
- data/spec/aws/s3_spec.rb +5 -0
- data/spec/aws/simpledb_spec.rb +13 -3
- data/spec/catalog/add_spec.rb +28 -0
- data/spec/catalog/delete_spec.rb +35 -0
- data/spec/catalog/list_spec.rb +21 -0
- data/spec/catalog/setup_spec.rb +29 -0
- data/spec/catalog/show_spec.rb +32 -0
- data/spec/catalog/verify_spec.rb +47 -0
- data/spec/catalog_spec.rb +63 -0
- data/spec/cli/catalog_spec.rb +42 -0
- data/spec/cli/destroy_spec.rb +1 -1
- data/spec/cli/download_spec.rb +68 -26
- data/spec/cli/setup_spec.rb +11 -4
- data/spec/cli/shared_spec.rb +23 -0
- data/spec/cli/teardown_spec.rb +52 -0
- data/spec/cli/upload_spec.rb +6 -5
- metadata +44 -17
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Teardowner do
|
4
|
+
before do
|
5
|
+
@regions = ['us-west-1', 'us-west-2']
|
6
|
+
@logger_stub = stub 'logger', :info => true, :debug => true
|
7
|
+
@config_stub = stub 'config', :logger => @logger_stub,
|
8
|
+
:metadata_region => 'us-west-1'
|
9
|
+
@verifier_stub = stub :bucket_exists? => true,
|
10
|
+
:domain_exists? => true
|
11
|
+
@teardowner = Heirloom::Teardowner.new :config => @config_stub,
|
12
|
+
:name => 'archive'
|
13
|
+
Heirloom::Verifier.stub :new => @verifier_stub
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should delete the buckets" do
|
17
|
+
@s3_mock1 = mock 's31'
|
18
|
+
@s3_mock2 = mock 's32'
|
19
|
+
Heirloom::AWS::S3.should_receive(:new).
|
20
|
+
with(:config => @config_stub,
|
21
|
+
:region => 'us-west-1').
|
22
|
+
and_return @s3_mock1
|
23
|
+
Heirloom::AWS::S3.should_receive(:new).
|
24
|
+
with(:config => @config_stub,
|
25
|
+
:region => 'us-west-2').
|
26
|
+
and_return @s3_mock2
|
27
|
+
@s3_mock1.should_receive(:delete_bucket).with('base-us-west-1')
|
28
|
+
@s3_mock2.should_receive(:delete_bucket).with('base-us-west-2')
|
29
|
+
@teardowner.delete_buckets :regions => @regions,
|
30
|
+
:bucket_prefix => 'base'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should delete the domain" do
|
34
|
+
@sdb_mock = mock 'sdb'
|
35
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
36
|
+
with(:config => @config_stub).
|
37
|
+
and_return @sdb_mock
|
38
|
+
@sdb_mock.should_receive(:delete_domain).
|
39
|
+
with 'heirloom_archive'
|
40
|
+
@teardowner.delete_domain
|
41
|
+
end
|
42
|
+
end
|
data/spec/archive_spec.rb
CHANGED
@@ -164,9 +164,8 @@ describe Heirloom do
|
|
164
164
|
:id => '123').
|
165
165
|
and_return destroyer_mock
|
166
166
|
destroyer_mock.should_receive(:destroy).
|
167
|
-
with
|
168
|
-
|
169
|
-
@archive.destroy :keep_domain => false
|
167
|
+
with :regions => ['us-west-1', 'us-west-2']
|
168
|
+
@archive.destroy
|
170
169
|
end
|
171
170
|
|
172
171
|
it "should call the regions method for an archive" do
|
@@ -190,5 +189,26 @@ describe Heirloom do
|
|
190
189
|
mock.should_receive(:count)
|
191
190
|
@archive.count
|
192
191
|
end
|
192
|
+
|
193
|
+
it "should call the delete_buckets on teardowner" do
|
194
|
+
mock = double('Mock')
|
195
|
+
Heirloom::Teardowner.should_receive(:new).
|
196
|
+
with(:config => @config_mock,
|
197
|
+
:name => 'chef').
|
198
|
+
and_return mock
|
199
|
+
mock.should_receive(:delete_buckets).with :regions => ['us-west-1']
|
200
|
+
@archive.delete_buckets :regions => ['us-west-1']
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should call the delete_domain on teardowner" do
|
204
|
+
mock = double('Mock')
|
205
|
+
Heirloom::Teardowner.should_receive(:new).
|
206
|
+
with(:config => @config_mock,
|
207
|
+
:name => 'chef').
|
208
|
+
and_return mock
|
209
|
+
mock.should_receive(:delete_domain)
|
210
|
+
@archive.delete_domain
|
211
|
+
end
|
212
|
+
|
193
213
|
end
|
194
214
|
end
|
data/spec/aws/s3_spec.rb
CHANGED
@@ -27,6 +27,11 @@ describe Heirloom do
|
|
27
27
|
@s3.get_bucket 'bucket'
|
28
28
|
end
|
29
29
|
|
30
|
+
it "should delete a bucket from s3" do
|
31
|
+
@fog_mock.should_receive(:delete_bucket).with 'bucket'
|
32
|
+
@s3.delete_bucket 'bucket'
|
33
|
+
end
|
34
|
+
|
30
35
|
it "should get an object from s3" do
|
31
36
|
body_mock = mock 'body'
|
32
37
|
@fog_mock.should_receive(:get_object).
|
data/spec/aws/simpledb_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe Heirloom do
|
|
56
56
|
body_mock = mock 'return body'
|
57
57
|
data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
|
58
58
|
@fog_mock.should_receive(:select).
|
59
|
-
with('SELECT count(*) FROM heirloom_domain').
|
59
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
60
60
|
and_return body_mock
|
61
61
|
body_mock.should_receive(:body).and_return data
|
62
62
|
@sdb.count('heirloom_domain').should == 1
|
@@ -66,7 +66,7 @@ describe Heirloom do
|
|
66
66
|
body_mock = mock 'return body'
|
67
67
|
data = { 'Items' => { 'Domain' => { 'Count' => ['0'] } } }
|
68
68
|
@fog_mock.should_receive(:select).
|
69
|
-
with('SELECT count(*) FROM heirloom_domain').
|
69
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
70
70
|
and_return body_mock
|
71
71
|
body_mock.should_receive(:body).and_return data
|
72
72
|
@sdb.domain_empty?('heirloom_domain').should be_true
|
@@ -76,10 +76,20 @@ describe Heirloom do
|
|
76
76
|
body_mock = mock 'return body'
|
77
77
|
data = { 'Items' => { 'Domain' => { 'Count' => ['50'] } } }
|
78
78
|
@fog_mock.should_receive(:select).
|
79
|
-
with('SELECT count(*) FROM heirloom_domain').
|
79
|
+
with('SELECT count(*) FROM `heirloom_domain`').
|
80
80
|
and_return body_mock
|
81
81
|
body_mock.should_receive(:body).and_return data
|
82
82
|
@sdb.domain_empty?('heirloom_domain').should be_false
|
83
83
|
end
|
84
84
|
|
85
|
+
it "should return the count for a specific itemName within a domain" do
|
86
|
+
body_mock = mock 'return body'
|
87
|
+
data = { 'Items' => { 'Domain' => { 'Count' => ['1'] } } }
|
88
|
+
@fog_mock.should_receive(:select).
|
89
|
+
with("SELECT count(*) FROM `heirloom` WHERE itemName() = 'archive'").
|
90
|
+
and_return body_mock
|
91
|
+
body_mock.should_receive(:body).and_return data
|
92
|
+
@sdb.item_count('heirloom', 'archive').should == 1
|
93
|
+
end
|
94
|
+
|
85
95
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::Add do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@regions = ['us-west-1', 'us-west-2']
|
7
|
+
@base = 'base'
|
8
|
+
@logger_stub = stub 'logger', :info => true
|
9
|
+
@config_stub = stub 'config', :logger => @logger_stub
|
10
|
+
@add = Heirloom::Catalog::Add.new :config => @config_stub,
|
11
|
+
:name => 'new_archive'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should call sdb to add the entry to the catalog" do
|
15
|
+
@sdb_mock = mock 'sdb'
|
16
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
17
|
+
with(:config => @config_stub).
|
18
|
+
and_return @sdb_mock
|
19
|
+
@sdb_mock.should_receive(:put_attributes).
|
20
|
+
with 'heirloom',
|
21
|
+
'heirloom_new_archive',
|
22
|
+
{ "regions" => @regions,
|
23
|
+
"base" => @base }
|
24
|
+
@add.add_to_catalog :regions => @regions,
|
25
|
+
:base => @base
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::Delete do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@logger_stub = stub 'logger', :info => true
|
7
|
+
@config_stub = stub 'config', :logger => @logger_stub
|
8
|
+
@verify_mock = mock 'verify'
|
9
|
+
Heirloom::Catalog::Verify.should_receive(:new).
|
10
|
+
with(:config => @config_stub).
|
11
|
+
and_return @verify_mock
|
12
|
+
@delete = Heirloom::Catalog::Delete.new :config => @config_stub,
|
13
|
+
:name => 'old_archive'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should delete the entry from the catalog" do
|
17
|
+
@verify_mock.should_receive(:catalog_domain_exists?).
|
18
|
+
and_return true
|
19
|
+
@sdb_mock = mock 'sdb'
|
20
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
21
|
+
with(:config => @config_stub).
|
22
|
+
and_return @sdb_mock
|
23
|
+
@sdb_mock.should_receive(:delete).
|
24
|
+
with('heirloom', 'heirloom_old_archive').
|
25
|
+
and_return true
|
26
|
+
@delete.delete_from_catalog.should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return false if an entry does not exist in catalog" do
|
30
|
+
@verify_mock.should_receive(:catalog_domain_exists?).
|
31
|
+
and_return false
|
32
|
+
@delete.delete_from_catalog.should be_false
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::List do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@config_stub = stub 'config'
|
7
|
+
@sdb_mock = mock 'sdb'
|
8
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
9
|
+
with(:config => @config_stub).
|
10
|
+
and_return @sdb_mock
|
11
|
+
@list = Heirloom::Catalog::List.new :config => @config_stub
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should list all heirlooms in the catalog" do
|
15
|
+
@sdb_mock.should_receive(:select).
|
16
|
+
with("SELECT * FROM heirloom").
|
17
|
+
and_return 'result'
|
18
|
+
@list.all.should == 'result'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::Setup do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@logger_stub = stub 'logger', :info => true
|
7
|
+
@config_stub = stub 'config', :logger => @logger_stub,
|
8
|
+
:metadata_region => 'us-west-1'
|
9
|
+
@verify_mock = mock 'verify'
|
10
|
+
Heirloom::Catalog::Verify.should_receive(:new).
|
11
|
+
with(:config => @config_stub).
|
12
|
+
and_return @verify_mock
|
13
|
+
@setup = Heirloom::Catalog::Setup.new :config => @config_stub,
|
14
|
+
:name => 'new_archive'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should call sdb to create the catalog domain" do
|
18
|
+
@verify_mock.should_receive(:catalog_domain_exists?).
|
19
|
+
and_return false
|
20
|
+
@sdb_mock = mock 'sdb'
|
21
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
22
|
+
with(:config => @config_stub).
|
23
|
+
and_return @sdb_mock
|
24
|
+
@sdb_mock.should_receive(:create_domain).
|
25
|
+
with 'heirloom'
|
26
|
+
@setup.create_catalog_domain
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::Show do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@config_stub = stub 'config'
|
7
|
+
@sdb_mock = mock 'sdb'
|
8
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
9
|
+
with(:config => @config_stub).
|
10
|
+
and_return @sdb_mock
|
11
|
+
@show = Heirloom::Catalog::Show.new :config => @config_stub,
|
12
|
+
:name => 'a_archive'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the base" do
|
16
|
+
result = { 'heirloom_a_archive' => { 'base' => [ 'thebase' ] } }
|
17
|
+
@sdb_mock.should_receive(:select).
|
18
|
+
with("select base from heirloom where itemName() = 'heirloom_a_archive'").
|
19
|
+
and_return result
|
20
|
+
@show.base.should == 'thebase'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the regions" do
|
24
|
+
regions = ['us-west-1', 'us-west-2']
|
25
|
+
result = { 'heirloom_a_archive' => { 'regions' => @regions } }
|
26
|
+
@sdb_mock.should_receive(:select).
|
27
|
+
with("select regions from heirloom where itemName() = 'heirloom_a_archive'").
|
28
|
+
and_return result
|
29
|
+
@show.regions.should == @regions
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog::Verify do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@sdb_mock = mock 'sdb'
|
7
|
+
@logger_stub = stub 'logger', :info => true,
|
8
|
+
:debug => true
|
9
|
+
@config_stub = stub 'config', :logger => @logger_stub,
|
10
|
+
:metadata_region => 'us-west-1'
|
11
|
+
Heirloom::AWS::SimpleDB.should_receive(:new).
|
12
|
+
with(:config => @config_stub).
|
13
|
+
and_return @sdb_mock
|
14
|
+
@verify = Heirloom::Catalog::Verify.new :config => @config_stub,
|
15
|
+
:name => 'a_archive'
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
context "testing catalog_domain_exists" do
|
20
|
+
it "should return true if heirloom domain exists" do
|
21
|
+
@sdb_mock.should_receive(:domain_exists?).
|
22
|
+
with('heirloom').and_return true
|
23
|
+
@verify.catalog_domain_exists?.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return false if heirloom domain does not exists" do
|
27
|
+
@sdb_mock.should_receive(:domain_exists?).
|
28
|
+
with('heirloom').and_return false
|
29
|
+
@verify.catalog_domain_exists?.should be_false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "testing entry_exists_in_catalog?" do
|
34
|
+
it "should return true if an entry exists in catalog" do
|
35
|
+
@sdb_mock.should_receive(:item_count).
|
36
|
+
with('heirloom', 'heirloom_a_archive').and_return 1
|
37
|
+
@verify.entry_exists_in_catalog?('a_archive').should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return false if an entry does not exist in catalog" do
|
41
|
+
@sdb_mock.should_receive(:item_count).
|
42
|
+
with('heirloom', 'heirloom_a_archive').and_return 0
|
43
|
+
@verify.entry_exists_in_catalog?('a_archive').should be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Heirloom::Catalog do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@config_mock = mock 'catalog'
|
7
|
+
@regions = ['us-west-1', 'us-west-2']
|
8
|
+
@base = 'thebase'
|
9
|
+
@catalog = Heirloom::Catalog.new :config => @config_mock,
|
10
|
+
:name => 'new_archive'
|
11
|
+
end
|
12
|
+
|
13
|
+
context "testing add" do
|
14
|
+
it "should call setup to create catalog_domain" do
|
15
|
+
@catalog_setup_mock = mock 'setup'
|
16
|
+
Heirloom::Catalog::Setup.should_receive(:new).
|
17
|
+
with(:config => @config_mock).
|
18
|
+
and_return @catalog_setup_mock
|
19
|
+
@catalog_setup_mock.should_receive(:create_catalog_domain).
|
20
|
+
and_return true
|
21
|
+
@catalog.create_catalog_domain.should be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "testing setup" do
|
26
|
+
it "should call setup to add_to_catalog" do
|
27
|
+
@catalog_add_mock = mock 'add'
|
28
|
+
Heirloom::Catalog::Add.should_receive(:new).
|
29
|
+
with(:config => @config_mock,
|
30
|
+
:name => 'new_archive').
|
31
|
+
and_return @catalog_add_mock
|
32
|
+
@catalog_add_mock.should_receive(:add_to_catalog).
|
33
|
+
with(:base => @base,
|
34
|
+
:regions => @regions).
|
35
|
+
and_return true
|
36
|
+
@catalog.add_to_catalog(:base => @base,
|
37
|
+
:regions => @regions).
|
38
|
+
should be_true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "testing show" do
|
43
|
+
before do
|
44
|
+
@catalog_show_mock = mock 'show'
|
45
|
+
Heirloom::Catalog::Show.should_receive(:new).
|
46
|
+
with(:config => @config_mock,
|
47
|
+
:name => 'new_archive').
|
48
|
+
and_return @catalog_show_mock
|
49
|
+
end
|
50
|
+
it "should call regions from show object" do
|
51
|
+
@catalog_show_mock.should_receive(:regions).
|
52
|
+
and_return @regions
|
53
|
+
@catalog.regions.should == @regions
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should call base from the show object" do
|
57
|
+
@catalog_show_mock.should_receive(:base).
|
58
|
+
and_return @base
|
59
|
+
@catalog.base.should == @base
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'heirloom/cli'
|
3
|
+
|
4
|
+
describe Heirloom do
|
5
|
+
|
6
|
+
before do
|
7
|
+
options = { :level => 'info',
|
8
|
+
:metadata_region => 'us-west-1',
|
9
|
+
:details => true }
|
10
|
+
@result = { 'heirloom_test' =>
|
11
|
+
{ 'regions' => ['us-west-1'],
|
12
|
+
'base' => ['base'] } }
|
13
|
+
@logger_stub = stub :debug => true
|
14
|
+
@config_mock = mock 'config'
|
15
|
+
@catalog_mock = mock 'catalog'
|
16
|
+
@config_mock.stub :logger => @logger_mock,
|
17
|
+
:access_key => 'key',
|
18
|
+
:secret_key => 'secret',
|
19
|
+
:metadata_region => 'us-west-1'
|
20
|
+
Trollop.stub(:options).and_return options
|
21
|
+
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
22
|
+
and_return @logger_stub
|
23
|
+
Heirloom::CLI::Catalog.any_instance.should_receive(:load_config).
|
24
|
+
with(:logger => @logger_stub,
|
25
|
+
:opts => options).
|
26
|
+
and_return @config_mock
|
27
|
+
Heirloom::Catalog.should_receive(:new).
|
28
|
+
with(:config => @config_mock).
|
29
|
+
and_return @catalog_mock
|
30
|
+
@cli_catalog = Heirloom::CLI::Catalog.new
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should list the details about all heirlooms in the catalog" do
|
34
|
+
@catalog_mock.should_receive(:all).and_return @result
|
35
|
+
formated_result = { 'test' =>
|
36
|
+
{ 'regions' => ['us-west-1'],
|
37
|
+
'base' => ['base'] } }
|
38
|
+
@cli_catalog.should_receive(:jj).with formated_result
|
39
|
+
@cli_catalog.list
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/spec/cli/destroy_spec.rb
CHANGED
data/spec/cli/download_spec.rb
CHANGED
@@ -4,14 +4,6 @@ require 'heirloom/cli'
|
|
4
4
|
describe Heirloom do
|
5
5
|
|
6
6
|
before do
|
7
|
-
options = { :name => 'archive_name',
|
8
|
-
:id => '1.0.0',
|
9
|
-
:level => 'info',
|
10
|
-
:output => '/tmp/test123',
|
11
|
-
:region => 'us-east-1',
|
12
|
-
:extract => false,
|
13
|
-
:metadata_region => 'us-west-1',
|
14
|
-
:base => 'base' }
|
15
7
|
@logger_stub = stub 'logger'
|
16
8
|
@config_mock = mock 'config'
|
17
9
|
@archive_mock = mock 'archive'
|
@@ -19,34 +11,84 @@ describe Heirloom do
|
|
19
11
|
:access_key => 'key',
|
20
12
|
:secret_key => 'secret',
|
21
13
|
:metadata_region => 'us-west-1'
|
22
|
-
Trollop.stub(:options).and_return options
|
23
14
|
Heirloom::HeirloomLogger.should_receive(:new).
|
24
15
|
with(:log_level => 'info').
|
25
16
|
and_return @logger_stub
|
26
|
-
Heirloom::CLI::Download.any_instance.should_receive(:load_config).
|
27
|
-
with(:logger => @logger_stub,
|
28
|
-
:opts => options).
|
29
|
-
and_return @config_mock
|
30
17
|
Heirloom::Archive.should_receive(:new).
|
31
18
|
with(:id => '1.0.0',
|
32
19
|
:name => 'archive_name',
|
33
20
|
:config => @config_mock).
|
34
21
|
and_return @archive_mock
|
35
|
-
@cli_download = Heirloom::CLI::Download.new
|
36
22
|
end
|
37
23
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
24
|
+
context "with region and base specified" do
|
25
|
+
before do
|
26
|
+
options = { :name => 'archive_name',
|
27
|
+
:id => '1.0.0',
|
28
|
+
:base => 'base',
|
29
|
+
:region => 'us-east-1',
|
30
|
+
:level => 'info',
|
31
|
+
:output => '/tmp/test123',
|
32
|
+
:extract => false,
|
33
|
+
:metadata_region => 'us-west-1' }
|
34
|
+
Trollop.stub(:options).and_return options
|
35
|
+
Heirloom::CLI::Download.any_instance.should_receive(:load_config).
|
36
|
+
with(:logger => @logger_stub,
|
37
|
+
:opts => options).
|
38
|
+
and_return @config_mock
|
39
|
+
@cli_download = Heirloom::CLI::Download.new
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should download an archive" do
|
43
|
+
@archive_mock.should_receive(:download).with(:output => '/tmp/test123',
|
44
|
+
:region => 'us-east-1',
|
45
|
+
:base_prefix => 'base',
|
46
|
+
:extract => false,
|
47
|
+
:secret => nil).
|
48
|
+
and_return '/tmp/test123'
|
49
|
+
@cli_download.should_receive(:ensure_directory).
|
50
|
+
with(:config => @config_mock,
|
51
|
+
:path => '/tmp/test123').
|
52
|
+
and_return true
|
53
|
+
@cli_download.download
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "region and base not specified" do
|
58
|
+
before do
|
59
|
+
@catalog_stub = stub 'catalog', :regions => ['us-east-1', 'us-west-1'],
|
60
|
+
:base => 'base'
|
61
|
+
options = { :name => 'archive_name',
|
62
|
+
:id => '1.0.0',
|
63
|
+
:level => 'info',
|
64
|
+
:output => '/tmp/test123',
|
65
|
+
:extract => false,
|
66
|
+
:metadata_region => 'us-west-1' }
|
67
|
+
Trollop.stub(:options).and_return options
|
68
|
+
Heirloom::CLI::Download.any_instance.should_receive(:load_config).
|
69
|
+
with(:logger => @logger_stub,
|
70
|
+
:opts => options).
|
71
|
+
and_return @config_mock
|
72
|
+
Heirloom::Catalog.should_receive(:new).
|
73
|
+
with(:name => 'archive_name',
|
74
|
+
:config => @config_mock).
|
75
|
+
and_return @catalog_stub
|
76
|
+
@cli_download = Heirloom::CLI::Download.new
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should download the archive from the first region" do
|
80
|
+
@archive_mock.should_receive(:download).with(:output => '/tmp/test123',
|
81
|
+
:region => 'us-east-1',
|
82
|
+
:base_prefix => 'base',
|
83
|
+
:extract => false,
|
84
|
+
:secret => nil).
|
85
|
+
and_return '/tmp/test123'
|
86
|
+
@cli_download.should_receive(:ensure_directory).
|
87
|
+
with(:config => @config_mock,
|
88
|
+
:path => '/tmp/test123').
|
89
|
+
and_return true
|
90
|
+
@cli_download.download
|
91
|
+
end
|
50
92
|
end
|
51
93
|
|
52
94
|
end
|
data/spec/cli/setup_spec.rb
CHANGED
@@ -18,6 +18,7 @@ describe Heirloom do
|
|
18
18
|
:secret_key => 'secret',
|
19
19
|
:metadata_region => 'us-west-1'
|
20
20
|
@archive_mock = mock 'archive'
|
21
|
+
@catalog_mock = mock 'catalog'
|
21
22
|
Trollop.stub(:options).and_return options
|
22
23
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
23
24
|
and_return @logger_stub
|
@@ -29,13 +30,19 @@ describe Heirloom do
|
|
29
30
|
with(:name => 'archive_name',
|
30
31
|
:config => @config_mock).
|
31
32
|
and_return @archive_mock
|
33
|
+
Heirloom::Catalog.should_receive(:new).
|
34
|
+
with(:name => 'archive_name',
|
35
|
+
:config => @config_mock).
|
36
|
+
and_return @catalog_mock
|
32
37
|
@setup = Heirloom::CLI::Setup.new
|
33
38
|
end
|
34
39
|
|
35
|
-
it "should setup s3 buckets and simpledb domain" do
|
36
|
-
@
|
37
|
-
|
38
|
-
|
40
|
+
it "should setup s3 buckets, catalog and simpledb domain" do
|
41
|
+
@catalog_mock.should_receive(:create_catalog_domain)
|
42
|
+
@catalog_mock.should_receive(:add_to_catalog).
|
43
|
+
with(:regions => @regions,
|
44
|
+
:base => 'base').
|
45
|
+
and_return true
|
39
46
|
@archive_mock.should_receive(:setup).
|
40
47
|
with(:regions => @regions,
|
41
48
|
:bucket_prefix => 'base')
|
data/spec/cli/shared_spec.rb
CHANGED
@@ -223,5 +223,28 @@ describe Heirloom do
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
+
context "testing ensure archive domain empty" do
|
227
|
+
before do
|
228
|
+
@archive_mock = mock 'archive'
|
229
|
+
@logger_stub = stub 'logger', :error => true
|
230
|
+
@config_stub = stub 'config', :logger => @logger_stub,
|
231
|
+
:metadata_region => 'us-west-1'
|
232
|
+
@options = { :config => @config_stub, :archive => @archive_mock }
|
233
|
+
@object = Object.new
|
234
|
+
@object.extend Heirloom::CLI::Shared
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should ensure the domain is empty" do
|
238
|
+
@archive_mock.should_receive(:count).and_return 0
|
239
|
+
@object.ensure_archive_domain_empty @options
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should exit if the domain is not empty" do
|
243
|
+
@archive_mock.should_receive(:count).and_return 200
|
244
|
+
lambda { @object.ensure_archive_domain_empty @options }.
|
245
|
+
should raise_error SystemExit
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
226
249
|
|
227
250
|
end
|