heirloom 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +12 -6
- data/heirloom.gemspec +3 -5
- data/lib/heirloom/catalog/verify.rb +2 -2
- data/lib/heirloom/cli/authorize.rb +1 -2
- data/lib/heirloom/cli/catalog.rb +62 -19
- data/lib/heirloom/cli/cleanup.rb +1 -2
- data/lib/heirloom/cli/destroy.rb +1 -2
- data/lib/heirloom/cli/download.rb +2 -3
- data/lib/heirloom/cli/formatter/catalog.rb +25 -11
- data/lib/heirloom/cli/list.rb +1 -3
- data/lib/heirloom/cli/rotate.rb +1 -2
- data/lib/heirloom/cli/setup.rb +1 -2
- data/lib/heirloom/cli/shared.rb +3 -0
- data/lib/heirloom/cli/show.rb +1 -3
- data/lib/heirloom/cli/tag.rb +1 -2
- data/lib/heirloom/cli/teardown.rb +1 -2
- data/lib/heirloom/cli/upload.rb +1 -2
- data/lib/heirloom/version.rb +1 -1
- data/spec/acl/s3_spec.rb +11 -11
- data/spec/archive/authorizer_spec.rb +20 -20
- data/spec/archive/builder_spec.rb +13 -13
- data/spec/archive/checker_spec.rb +24 -24
- data/spec/archive/destroyer_spec.rb +20 -20
- data/spec/archive/downloader_spec.rb +30 -30
- data/spec/archive/lister_spec.rb +7 -7
- data/spec/archive/reader_spec.rb +65 -65
- data/spec/archive/setup_spec.rb +27 -27
- data/spec/archive/teardowner_spec.rb +19 -19
- data/spec/archive/updater_spec.rb +10 -10
- data/spec/archive/uploader_spec.rb +26 -26
- data/spec/archive/verifier_spec.rb +25 -25
- data/spec/archive/writer_spec.rb +11 -11
- data/spec/archive_spec.rb +91 -93
- data/spec/aws/s3_spec.rb +102 -102
- data/spec/aws/simpledb_spec.rb +33 -63
- data/spec/catalog/add_spec.rb +12 -12
- data/spec/catalog/delete_spec.rb +14 -14
- data/spec/catalog/list_spec.rb +8 -8
- data/spec/catalog/setup_spec.rb +11 -11
- data/spec/catalog/show_spec.rb +13 -13
- data/spec/catalog/verify_spec.rb +16 -16
- data/spec/catalog_spec.rb +36 -36
- data/spec/cipher/data_spec.rb +19 -19
- data/spec/cipher/file_spec.rb +11 -11
- data/spec/cli/authorize_spec.rb +16 -16
- data/spec/cli/catalog_spec.rb +18 -34
- data/spec/cli/destroy_spec.rb +13 -13
- data/spec/cli/download_spec.rb +31 -31
- data/spec/cli/formatter/catalog_spec.rb +19 -17
- data/spec/cli/list_spec.rb +14 -14
- data/spec/cli/rotate_spec.rb +9 -9
- data/spec/cli/setup_spec.rb +29 -29
- data/spec/cli/shared_spec.rb +119 -119
- data/spec/cli/show_spec.rb +20 -20
- data/spec/cli/tag_spec.rb +18 -18
- data/spec/cli/teardown_spec.rb +28 -28
- data/spec/cli/upload_spec.rb +38 -38
- data/spec/config_spec.rb +21 -21
- data/spec/destroyer/s3_spec.rb +6 -6
- data/spec/directory/directory_spec.rb +19 -19
- data/spec/downloader/s3_spec.rb +18 -18
- data/spec/logger_spec.rb +9 -9
- data/spec/spec_helper.rb +4 -80
- data/spec/uploader/s3_spec.rb +35 -35
- metadata +23 -56
- data/spec/integration/authorize_spec.rb +0 -79
- data/spec/integration/cleanup_spec.rb +0 -77
- data/watchr.rb +0 -101
data/spec/cli/show_spec.rb
CHANGED
@@ -9,26 +9,26 @@ describe Heirloom do
|
|
9
9
|
:id => '1.0.0',
|
10
10
|
:level => 'info',
|
11
11
|
:metadata_region => 'us-west-1' }
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
12
|
+
@logger_double = double :debug => true
|
13
|
+
@config_double = double_config(:logger => @logger_double)
|
14
|
+
@archive_double = double 'archive'
|
15
15
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
16
|
-
and_return @
|
16
|
+
and_return @logger_double
|
17
17
|
Heirloom::CLI::Show.any_instance.should_receive(:load_config).
|
18
|
-
with(:logger => @
|
18
|
+
with(:logger => @logger_double,
|
19
19
|
:opts => @options).
|
20
|
-
and_return @
|
20
|
+
and_return @config_double
|
21
21
|
Heirloom::Archive.should_receive(:new).
|
22
22
|
with(:name => 'archive_name',
|
23
|
-
:config => @
|
24
|
-
and_return @
|
23
|
+
:config => @config_double).
|
24
|
+
and_return @archive_double
|
25
25
|
Heirloom::Archive.should_receive(:new).
|
26
26
|
with(:name => 'archive_name',
|
27
27
|
:id => '1.0.0',
|
28
|
-
:config => @
|
29
|
-
and_return @
|
30
|
-
@
|
31
|
-
@
|
28
|
+
:config => @config_double).
|
29
|
+
and_return @archive_double
|
30
|
+
@archive_double.stub :exists? => true
|
31
|
+
@archive_double.stub :domain_exists? => true
|
32
32
|
end
|
33
33
|
|
34
34
|
context "returning base attributes" do
|
@@ -44,7 +44,7 @@ describe Heirloom do
|
|
44
44
|
|
45
45
|
it "should show a given id as json" do
|
46
46
|
@cli_show = Heirloom::CLI::Show.new
|
47
|
-
@
|
47
|
+
@archive_double.stub :show => @attributes
|
48
48
|
@cli_show.should_receive(:jj).with @attributes
|
49
49
|
@cli_show.show
|
50
50
|
end
|
@@ -59,13 +59,13 @@ describe Heirloom do
|
|
59
59
|
|
60
60
|
it "should show a given id using the show formatter" do
|
61
61
|
@cli_show = Heirloom::CLI::Show.new
|
62
|
-
@
|
63
|
-
|
64
|
-
Heirloom::CLI::Formatter::Show.stub :new =>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
@archive_double.stub :show => @attributes
|
63
|
+
formatter_double = double 'format'
|
64
|
+
Heirloom::CLI::Formatter::Show.stub :new => formatter_double
|
65
|
+
formatter_double.should_receive(:format).
|
66
|
+
with(:attributes => @attributes,
|
67
|
+
:all => true).
|
68
|
+
and_return 'the attribs'
|
69
69
|
@cli_show.should_receive(:puts).with 'the attribs'
|
70
70
|
@cli_show.show
|
71
71
|
end
|
data/spec/cli/tag_spec.rb
CHANGED
@@ -10,41 +10,41 @@ describe Heirloom do
|
|
10
10
|
:attribute => 'att',
|
11
11
|
:value => 'val',
|
12
12
|
:metadata_region => 'us-west-1' }
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
|
13
|
+
@logger_double = double :debug => true, :error => true
|
14
|
+
@config_double = double_config(:logger => @logger_double)
|
15
|
+
@archive_double = double 'archive'
|
16
|
+
|
17
17
|
Trollop.stub(:options).and_return options
|
18
18
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
19
|
-
and_return @
|
19
|
+
and_return @logger_double
|
20
20
|
Heirloom::CLI::Tag.any_instance.should_receive(:load_config).
|
21
|
-
with(:logger => @
|
21
|
+
with(:logger => @logger_double,
|
22
22
|
:opts => options).
|
23
|
-
and_return @
|
23
|
+
and_return @config_double
|
24
24
|
Heirloom::Archive.should_receive(:new).
|
25
25
|
with(:name => 'archive_name',
|
26
|
-
:config => @
|
27
|
-
and_return @
|
26
|
+
:config => @config_double).
|
27
|
+
and_return @archive_double
|
28
28
|
Heirloom::Archive.should_receive(:new).
|
29
29
|
with(:name => 'archive_name',
|
30
30
|
:id => '1.0.0',
|
31
|
-
:config => @
|
32
|
-
and_return @
|
33
|
-
@
|
34
|
-
@
|
31
|
+
:config => @config_double).
|
32
|
+
and_return @archive_double
|
33
|
+
@archive_double.stub :exists? => true
|
34
|
+
@archive_double.should_receive(:domain_exists?).and_return true
|
35
35
|
@cli_tag = Heirloom::CLI::Tag.new
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should tag an archive attribute with a given id" do
|
39
|
-
@
|
40
|
-
@
|
41
|
-
|
42
|
-
|
39
|
+
@archive_double.stub :exists? => true
|
40
|
+
@archive_double.should_receive(:update).
|
41
|
+
with(:attribute => 'att',
|
42
|
+
:value => 'val')
|
43
43
|
@cli_tag.tag
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should exit if the archive does not exist" do
|
47
|
-
@
|
47
|
+
@archive_double.stub :exists? => false
|
48
48
|
lambda { @cli_tag.tag }.should raise_error SystemExit
|
49
49
|
end
|
50
50
|
|
data/spec/cli/teardown_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'heirloom/cli'
|
|
3
3
|
|
4
4
|
describe Heirloom::CLI::Teardown do
|
5
5
|
|
6
|
-
def
|
6
|
+
def doublebed_teardown
|
7
7
|
teardown = Heirloom::CLI::Teardown.new
|
8
8
|
teardown.stub(
|
9
9
|
:ensure_domain_exists => true,
|
@@ -13,46 +13,46 @@ describe Heirloom::CLI::Teardown do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before do
|
16
|
-
Heirloom.stub :log =>
|
17
|
-
@
|
16
|
+
Heirloom.stub :log => double_log
|
17
|
+
@config_double = double_config
|
18
18
|
|
19
|
-
@defaults = {
|
19
|
+
@defaults = {
|
20
20
|
:level => 'info',
|
21
21
|
:name => 'archive_name',
|
22
22
|
:metadata_region => 'us-west-1'
|
23
23
|
}
|
24
24
|
|
25
25
|
|
26
|
-
@
|
27
|
-
@
|
26
|
+
@archive_double = double 'archive'
|
27
|
+
@archive_double.stub(
|
28
28
|
:delete_buckets => true,
|
29
29
|
:delete_domain => true
|
30
30
|
)
|
31
31
|
|
32
|
-
@
|
33
|
-
@
|
32
|
+
@catalog_double = double 'catalog'
|
33
|
+
@catalog_double.stub(
|
34
34
|
:regions => ['us-west-1', 'us-west-2'],
|
35
|
-
:bucket_prefix => 'bp',
|
35
|
+
:bucket_prefix => 'bp',
|
36
36
|
:catalog_domain_exists? => true,
|
37
37
|
:delete_from_catalog => true,
|
38
38
|
:entry_exists_in_catalog? => true
|
39
39
|
)
|
40
|
-
|
40
|
+
|
41
41
|
Trollop.stub :options => @defaults
|
42
|
-
Heirloom::HeirloomLogger.stub :new => @
|
42
|
+
Heirloom::HeirloomLogger.stub :new => @logger_double
|
43
43
|
Heirloom::CLI::Teardown.any_instance.stub(:load_config)
|
44
|
-
.and_return @
|
45
|
-
Heirloom::Archive.stub :new => @
|
46
|
-
Heirloom::Catalog.stub :new => @
|
47
|
-
@teardown =
|
44
|
+
.and_return @config_double
|
45
|
+
Heirloom::Archive.stub :new => @archive_double
|
46
|
+
Heirloom::Catalog.stub :new => @catalog_double
|
47
|
+
@teardown = doublebed_teardown
|
48
48
|
end
|
49
49
|
|
50
50
|
context "delete existing archives force option" do
|
51
|
-
|
51
|
+
|
52
52
|
it "should ask archive to delete when passed the 'force' option" do
|
53
53
|
Trollop.stub :options => @defaults.merge(:force => true)
|
54
|
-
@teardown =
|
55
|
-
@
|
54
|
+
@teardown = doublebed_teardown
|
55
|
+
@catalog_double.should_receive(:cleanup).with(
|
56
56
|
:num_to_keep => 0,
|
57
57
|
:remove_preserved => true
|
58
58
|
)
|
@@ -61,24 +61,24 @@ describe Heirloom::CLI::Teardown do
|
|
61
61
|
|
62
62
|
it "should not ask archive to delete when not passed the 'force' option" do
|
63
63
|
Trollop.stub :options => @defaults.merge(:force => nil)
|
64
|
-
@teardown =
|
65
|
-
@
|
64
|
+
@teardown = doublebed_teardown
|
65
|
+
@catalog_double.should_not_receive(:cleanup)
|
66
66
|
@teardown.teardown
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should delete s3 buckets, catalog and simpledb domain" do
|
72
72
|
@teardown.should_receive(:ensure_domain_exists).
|
73
73
|
with(:name => 'archive_name',
|
74
|
-
:config => @
|
74
|
+
:config => @config_double)
|
75
75
|
@teardown.should_receive(:ensure_archive_domain_empty).
|
76
|
-
with(:archive => @
|
77
|
-
:config => @
|
78
|
-
@
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@teardown.teardown
|
76
|
+
with(:archive => @archive_double,
|
77
|
+
:config => @config_double)
|
78
|
+
@archive_double.should_receive(:delete_buckets)
|
79
|
+
@archive_double.should_receive(:delete_domain)
|
80
|
+
@catalog_double.should_receive(:delete_from_catalog)
|
81
|
+
@teardown.teardown
|
82
82
|
end
|
83
83
|
|
84
84
|
end
|
data/spec/cli/upload_spec.rb
CHANGED
@@ -11,71 +11,71 @@ describe Heirloom do
|
|
11
11
|
:public => false,
|
12
12
|
:secret => 'secret12',
|
13
13
|
:name => 'archive_name',
|
14
|
-
:id => '1.0.0',
|
14
|
+
:id => '1.0.0',
|
15
15
|
:metadata_region => 'us-west-1' }
|
16
16
|
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
17
|
+
@logger_double = double 'logger', :error => true, :info => true
|
18
|
+
@config_double = double_config(:logger => @logger_double)
|
19
|
+
@archive_double = double 'archive'
|
20
|
+
@catalog_double = double 'catalog'
|
21
|
+
@catalog_double.stub :regions => @regions,
|
22
22
|
:bucket_prefix => 'bp',
|
23
23
|
:catalog_domain_exists? => true
|
24
24
|
Trollop.stub(:options).and_return options
|
25
|
-
|
26
|
-
|
27
|
-
Tempfile.stub :new =>
|
28
|
-
|
25
|
+
tempfile_double = double 'tempfile', :path => '/tmp/file.tar.gz',
|
26
|
+
:close! => true
|
27
|
+
Tempfile.stub :new => tempfile_double
|
28
|
+
|
29
29
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
30
|
-
and_return @
|
30
|
+
and_return @logger_double
|
31
31
|
Heirloom::CLI::Upload.any_instance.should_receive(:load_config).
|
32
|
-
with(:logger => @
|
32
|
+
with(:logger => @logger_double,
|
33
33
|
:opts => options).
|
34
|
-
and_return @
|
34
|
+
and_return @config_double
|
35
35
|
Heirloom::Archive.should_receive(:new).
|
36
36
|
with(:id => '1.0.0',
|
37
37
|
:name => 'archive_name',
|
38
|
-
:config => @
|
39
|
-
and_return @
|
38
|
+
:config => @config_double).
|
39
|
+
and_return @archive_double
|
40
40
|
Heirloom::Catalog.should_receive(:new).
|
41
41
|
with(:name => 'archive_name',
|
42
|
-
:config => @
|
43
|
-
and_return @
|
44
|
-
@
|
45
|
-
|
46
|
-
|
42
|
+
:config => @config_double).
|
43
|
+
and_return @catalog_double
|
44
|
+
@catalog_double.should_receive(:entry_exists_in_catalog?).
|
45
|
+
with('archive_name').
|
46
|
+
and_return true
|
47
47
|
@upload = Heirloom::CLI::Upload.new
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should upload an archive" do
|
51
51
|
@upload.should_receive(:ensure_domain_exists).
|
52
52
|
with(:name => 'archive_name',
|
53
|
-
:config => @
|
53
|
+
:config => @config_double)
|
54
54
|
@upload.should_receive(:ensure_buckets_exist).
|
55
55
|
with(:bucket_prefix => 'bp',
|
56
56
|
:name => 'archive_name',
|
57
57
|
:regions => @regions,
|
58
|
-
:config => @
|
58
|
+
:config => @config_double)
|
59
59
|
@upload.should_receive(:ensure_path_is_directory).
|
60
60
|
with(:path => '/buildme',
|
61
|
-
:config => @
|
61
|
+
:config => @config_double)
|
62
62
|
@upload.should_receive(:ensure_valid_secret).
|
63
63
|
with(:secret => 'secret12',
|
64
|
-
:config => @
|
65
|
-
@
|
66
|
-
@
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
64
|
+
:config => @config_double)
|
65
|
+
@archive_double.stub :exists? => false
|
66
|
+
@archive_double.should_receive(:build).
|
67
|
+
with(:bucket_prefix => 'bp',
|
68
|
+
:directory => '/buildme',
|
69
|
+
:exclude => ["exclude1", "exclude2"],
|
70
|
+
:secret => 'secret12',
|
71
|
+
:file => '/tmp/file.tar.gz').
|
72
|
+
and_return true
|
73
|
+
@archive_double.should_receive(:upload).
|
74
|
+
with(:bucket_prefix => 'bp',
|
75
|
+
:regions => @regions,
|
76
|
+
:public_readable => false,
|
77
|
+
:secret => 'secret12',
|
78
|
+
:file => '/tmp/file.tar.gz')
|
79
79
|
@upload.upload
|
80
80
|
end
|
81
81
|
|
data/spec/config_spec.rb
CHANGED
@@ -23,9 +23,9 @@ describe Heirloom do
|
|
23
23
|
it "should open the HEIRLOOM_CONFIG_FILE if set" do
|
24
24
|
File.stub :exists? => true
|
25
25
|
File.should_receive(:open).with('~/.special_config.yml').and_return(@config_file.to_yaml)
|
26
|
-
|
27
|
-
|
28
|
-
Heirloom::Env.stub(:new).and_return(
|
26
|
+
env_double = double 'env'
|
27
|
+
env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return('~/.special_config.yml')
|
28
|
+
Heirloom::Env.stub(:new).and_return(env_double)
|
29
29
|
config = Heirloom::Config.new :opts => @opts,
|
30
30
|
:logger => 'da-logger'
|
31
31
|
end
|
@@ -33,10 +33,10 @@ describe Heirloom do
|
|
33
33
|
it "should open the default config file if HEIRLOOM_CONFIG_FILE is not set" do
|
34
34
|
File.stub :exists? => true
|
35
35
|
File.should_receive(:open).with('~/.heirloom.yml').and_return(@config_file.to_yaml)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Heirloom::Env.stub(:new).and_return(
|
36
|
+
env_double = double 'env'
|
37
|
+
env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
|
38
|
+
env_double.should_receive(:load).with('HOME').and_return('~')
|
39
|
+
Heirloom::Env.stub(:new).and_return(env_double)
|
40
40
|
config = Heirloom::Config.new :opts => @opts,
|
41
41
|
:logger => 'da-logger'
|
42
42
|
end
|
@@ -44,11 +44,11 @@ describe Heirloom do
|
|
44
44
|
|
45
45
|
context "#reading env variables" do
|
46
46
|
it "should return the proxy as set by https_proxy" do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Heirloom::Env.stub(:new).and_return(
|
47
|
+
env_double = double 'env'
|
48
|
+
env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
|
49
|
+
env_double.should_receive(:load).with('HOME').and_return('~')
|
50
|
+
env_double.should_receive(:load).with('https_proxy').and_return('https://proxy.example.com:3128')
|
51
|
+
Heirloom::Env.stub(:new).and_return(env_double)
|
52
52
|
config = Heirloom::Config.new :opts => @opts
|
53
53
|
expect(config.proxy).to eq('https://proxy.example.com:3128')
|
54
54
|
end
|
@@ -56,10 +56,10 @@ describe Heirloom do
|
|
56
56
|
|
57
57
|
context "#with config file set" do
|
58
58
|
before do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
Heirloom::Env.stub(:new).and_return(
|
59
|
+
env_double = double 'env'
|
60
|
+
env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
|
61
|
+
env_double.should_receive(:load).with('HOME').and_return('~')
|
62
|
+
Heirloom::Env.stub(:new).and_return(env_double)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should create a new config object from the hash passed as config" do
|
@@ -123,12 +123,12 @@ describe Heirloom do
|
|
123
123
|
it "should log a warning if a non-existing environment is requested from existing config file" do
|
124
124
|
File.stub :exists? => true
|
125
125
|
File.should_receive(:open).with("~/.heirloom.yml").and_return(@config_file.to_yaml)
|
126
|
-
|
127
|
-
|
126
|
+
logger_double = double 'logger'
|
127
|
+
logger_double.should_receive(:warn)
|
128
128
|
|
129
|
-
|
130
|
-
config = Heirloom::Config.new :environment => 'missing', :logger =>
|
131
|
-
}.
|
129
|
+
expect {
|
130
|
+
config = Heirloom::Config.new :environment => 'missing', :logger => logger_double
|
131
|
+
}.not_to raise_error
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
data/spec/destroyer/s3_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Heirloom do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@
|
7
|
-
@s3 = Heirloom::Destroyer::S3.new :config => @
|
6
|
+
@config_double = double 'config'
|
7
|
+
@s3 = Heirloom::Destroyer::S3.new :config => @config_double,
|
8
8
|
:region => 'us-west-1'
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should delete the specified file from s3" do
|
12
|
-
|
13
|
-
@s3.should_receive(:s3).and_return(
|
14
|
-
|
15
|
-
|
12
|
+
s3_double = double 's3 mock'
|
13
|
+
@s3.should_receive(:s3).and_return(s3_double)
|
14
|
+
s3_double.should_receive(:delete_object).
|
15
|
+
with('bucket', "key_folder/key_name")
|
16
16
|
@s3.destroy_file :key_name => 'key_name',
|
17
17
|
:key_folder => 'key_folder',
|
18
18
|
:bucket => 'bucket'
|
@@ -4,13 +4,13 @@ describe Heirloom::Directory do
|
|
4
4
|
|
5
5
|
describe 'build_artifact_from_directory' do
|
6
6
|
before do
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
@directory = Heirloom::Directory.new :config => @
|
7
|
+
@config_double = double 'config'
|
8
|
+
@logger_double = double :debug => 'true',
|
9
|
+
:info => 'true',
|
10
|
+
:warn => 'true',
|
11
|
+
:error => 'true'
|
12
|
+
@config_double.stub(:logger).and_return(@logger_double)
|
13
|
+
@directory = Heirloom::Directory.new :config => @config_double,
|
14
14
|
:exclude => ['dont_pack_me', 'dont_pack_me1'],
|
15
15
|
:path => '/dir',
|
16
16
|
:file => '/tmp/file.tar.gz'
|
@@ -19,12 +19,12 @@ describe Heirloom::Directory do
|
|
19
19
|
context 'when succesful' do
|
20
20
|
before do
|
21
21
|
@directory.should_receive(:which).with('tar').and_return true
|
22
|
-
|
22
|
+
output_double = double 'output double'
|
23
23
|
command = "cd /dir && tar czf /tmp/file.tar.gz --exclude dont_pack_me --exclude dont_pack_me1 ."
|
24
24
|
files = ['pack_me', '.hidden', 'with a space', 'dont_pack_me', 'dont_pack_me1']
|
25
25
|
Heirloom::Directory.any_instance.should_receive(:`).
|
26
26
|
with(command).
|
27
|
-
and_return
|
27
|
+
and_return output_double
|
28
28
|
$?.stub :success? => true
|
29
29
|
end
|
30
30
|
|
@@ -37,17 +37,17 @@ describe Heirloom::Directory do
|
|
37
37
|
|
38
38
|
context 'without secret provided' do
|
39
39
|
before do
|
40
|
-
@
|
40
|
+
@cipher_double = double 'cipher'
|
41
41
|
Heirloom::Cipher::File.should_receive(:new).
|
42
|
-
with(:config => @
|
43
|
-
and_return @
|
42
|
+
with(:config => @config_double).
|
43
|
+
and_return @cipher_double
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should build and encrypt an archive from the path" do
|
47
|
-
@
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
@cipher_double.should_receive(:encrypt_file).
|
48
|
+
with(:file => '/tmp/file.tar.gz',
|
49
|
+
:secret => 'supersecret').
|
50
|
+
and_return true
|
51
51
|
@directory.build_artifact_from_directory(:secret => 'supersecret').
|
52
52
|
should be_true
|
53
53
|
end
|
@@ -57,12 +57,12 @@ describe Heirloom::Directory do
|
|
57
57
|
context 'when unable to create the tar' do
|
58
58
|
before do
|
59
59
|
@directory.should_receive(:which).with('tar').and_return true
|
60
|
-
|
60
|
+
output_double = double 'output double'
|
61
61
|
command = "cd /dir && tar czf /tmp/file.tar.gz --exclude dont_pack_me --exclude dont_pack_me1 ."
|
62
62
|
files = ['pack_me', '.hidden', 'with a space', 'dont_pack_me', 'dont_pack_me1']
|
63
63
|
Heirloom::Directory.any_instance.should_receive(:`).
|
64
64
|
with(command).
|
65
|
-
and_return
|
65
|
+
and_return output_double
|
66
66
|
$?.stub(:success?).and_return(false)
|
67
67
|
end
|
68
68
|
|
@@ -89,7 +89,7 @@ describe Heirloom::Directory do
|
|
89
89
|
|
90
90
|
context "parameter validation" do
|
91
91
|
it "should not fail if exclude is nil" do
|
92
|
-
@directory = Heirloom::Directory.new :config => @
|
92
|
+
@directory = Heirloom::Directory.new :config => @config_double,
|
93
93
|
:exclude => nil,
|
94
94
|
:path => '/dir',
|
95
95
|
:file => '/tmp/file.tar.gz'
|