heirloom 0.6.1 → 0.7.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG +11 -1
  2. data/lib/heirloom/acl/s3.rb +1 -1
  3. data/lib/heirloom/archive/authorizer.rb +1 -1
  4. data/lib/heirloom/archive/builder.rb +1 -3
  5. data/lib/heirloom/archive/destroyer.rb +2 -19
  6. data/lib/heirloom/archive/lister.rb +1 -1
  7. data/lib/heirloom/archive/reader.rb +1 -1
  8. data/lib/heirloom/archive/teardowner.rb +48 -0
  9. data/lib/heirloom/archive/verifier.rb +2 -2
  10. data/lib/heirloom/archive.rb +16 -3
  11. data/lib/heirloom/aws/s3.rb +8 -4
  12. data/lib/heirloom/aws/simpledb.rb +6 -1
  13. data/lib/heirloom/catalog/add.rb +31 -0
  14. data/lib/heirloom/catalog/delete.rb +37 -0
  15. data/lib/heirloom/catalog/list.rb +22 -0
  16. data/lib/heirloom/catalog/setup.rb +30 -0
  17. data/lib/heirloom/catalog/show.rb +35 -0
  18. data/lib/heirloom/catalog/verify.rb +39 -0
  19. data/lib/heirloom/catalog.rb +65 -0
  20. data/lib/heirloom/cli/authorize.rb +4 -4
  21. data/lib/heirloom/cli/catalog.rb +62 -0
  22. data/lib/heirloom/cli/destroy.rb +4 -4
  23. data/lib/heirloom/cli/download.rb +24 -13
  24. data/lib/heirloom/cli/list.rb +2 -2
  25. data/lib/heirloom/cli/setup.rb +21 -6
  26. data/lib/heirloom/cli/shared.rb +12 -3
  27. data/lib/heirloom/cli/show.rb +3 -3
  28. data/lib/heirloom/cli/tag.rb +3 -3
  29. data/lib/heirloom/cli/teardown.rb +75 -0
  30. data/lib/heirloom/cli/upload.rb +17 -26
  31. data/lib/heirloom/cli.rb +7 -1
  32. data/lib/heirloom/directory/directory.rb +1 -1
  33. data/lib/heirloom/version.rb +1 -1
  34. data/lib/heirloom.rb +7 -6
  35. data/spec/acl/s3_spec.rb +2 -7
  36. data/spec/archive/destroyer_spec.rb +4 -17
  37. data/spec/archive/lister_spec.rb +1 -1
  38. data/spec/archive/reader_spec.rb +9 -9
  39. data/spec/archive/teardowner_spec.rb +42 -0
  40. data/spec/archive_spec.rb +23 -3
  41. data/spec/aws/s3_spec.rb +5 -0
  42. data/spec/aws/simpledb_spec.rb +13 -3
  43. data/spec/catalog/add_spec.rb +28 -0
  44. data/spec/catalog/delete_spec.rb +35 -0
  45. data/spec/catalog/list_spec.rb +21 -0
  46. data/spec/catalog/setup_spec.rb +29 -0
  47. data/spec/catalog/show_spec.rb +32 -0
  48. data/spec/catalog/verify_spec.rb +47 -0
  49. data/spec/catalog_spec.rb +63 -0
  50. data/spec/cli/catalog_spec.rb +42 -0
  51. data/spec/cli/destroy_spec.rb +1 -1
  52. data/spec/cli/download_spec.rb +68 -26
  53. data/spec/cli/setup_spec.rb +11 -4
  54. data/spec/cli/shared_spec.rb +23 -0
  55. data/spec/cli/teardown_spec.rb +52 -0
  56. data/spec/cli/upload_spec.rb +6 -5
  57. metadata +44 -17
@@ -11,22 +11,29 @@ module Heirloom
11
11
  :opts => @opts
12
12
 
13
13
  ensure_valid_options :provided => @opts,
14
- :required => [:base, :name, :id, :output],
14
+ :required => [:name, :id, :output],
15
15
  :config => @config
16
16
 
17
+ @catalog = Heirloom::Catalog.new :name => @opts[:name],
18
+ :config => @config
17
19
  @archive = Archive.new :name => @opts[:name],
18
20
  :id => @opts[:id],
19
21
  :config => @config
22
+
23
+ # Lookup region & base from simpledb unless specified
24
+ # To Do, valid validation message that simpledb exists
25
+ @region = @opts[:region] || @catalog.regions.first
26
+ @base = @opts[:base] || @catalog.base
20
27
  end
21
28
 
22
29
  def download
23
30
  ensure_directory :path => @opts[:output], :config => @config
24
31
  ensure_valid_secret :secret => @opts[:secret], :config => @config
25
32
  archive = @archive.download :output => @opts[:output],
26
- :region => @opts[:region],
27
33
  :extract => @opts[:extract],
28
- :base_prefix => @opts[:base],
29
- :secret => @opts[:secret]
34
+ :secret => @opts[:secret],
35
+ :region => @region,
36
+ :base_prefix => @base
30
37
  exit 1 unless archive
31
38
  end
32
39
 
@@ -37,24 +44,28 @@ module Heirloom
37
44
  version Heirloom::VERSION
38
45
  banner <<-EOS
39
46
 
40
- Download an archive.
47
+ Download Heirloom.
41
48
 
42
49
  Usage:
43
50
 
44
- heirloom download -n NAME -i ID -r REGION -o OUTPUT_DIRECTORY
51
+ heirloom download -n NAME -i ID -o OUTPUT_DIRECTORY
52
+
53
+ To download Heirloom without looking up details in SimpleDB, specify region (-r) and base (-b) options.
45
54
 
46
55
  EOS
47
- opt :base, "Base of the archive to download.", :type => :string
48
- opt :extract, "Extract the archive in the given output path.", :short => "-x"
56
+ opt :base, "Base of the Heirloom to download.", :type => :string
57
+ opt :extract, "Extract the Heirloom into the given output path.", :short => "-x"
49
58
  opt :help, "Display Help"
50
- opt :id, "ID of the archive to download.", :type => :string
59
+ opt :id, "ID of the Heirloom to download.", :type => :string
51
60
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
52
61
  :default => 'info'
53
- opt :name, "Name of archive.", :type => :string
54
- opt :output, "Path to output downloaded archive. Must be existing directory.", :type => :string
55
- opt :region, "Region to download archive.", :type => :string,
62
+ opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
63
+ :default => 'us-west-1'
64
+ opt :name, "Name of Heirloom.", :type => :string
65
+ opt :output, "Path to output downloaded Heirloom. Must be existing directory.", :type => :string
66
+ opt :region, "Region to download Heirloom.", :type => :string,
56
67
  :default => 'us-west-1'
57
- opt :secret, "Secret for ecrypted archive.", :type => :string
68
+ opt :secret, "Secret for ecrypted Heirloom.", :type => :string
58
69
  opt :aws_access_key, "AWS Access Key ID", :type => :string,
59
70
  :short => :none
60
71
  opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
@@ -33,7 +33,7 @@ module Heirloom
33
33
  version Heirloom::VERSION
34
34
  banner <<-EOS
35
35
 
36
- List available IDs of archive.
36
+ List Heirloom IDs.
37
37
 
38
38
  Usage:
39
39
 
@@ -47,7 +47,7 @@ EOS
47
47
  :default => 'info'
48
48
  opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
49
49
  :default => 'us-west-1'
50
- opt :name, "Name of archive.", :type => :string
50
+ opt :name, "Name of Heirloom.", :type => :string
51
51
  opt :aws_access_key, "AWS Access Key ID", :type => :string,
52
52
  :short => :none
53
53
  opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
@@ -14,18 +14,32 @@ module Heirloom
14
14
  :required => [:metadata_region, :region,
15
15
  :name, :base],
16
16
  :config => @config
17
- ensure_valid_region :region => @opts[:metadata_region],
18
- :config => @config
19
- ensure_valid_regions :regions => @opts[:region],
20
- :config => @config
21
17
 
18
+ @catalog = Heirloom::Catalog.new :name => @opts[:name],
19
+ :config => @config
22
20
  @archive = Archive.new :name => @opts[:name],
23
21
  :config => @config
24
22
  end
25
23
 
26
24
  def setup
25
+ ensure_valid_region :region => @opts[:metadata_region],
26
+ :config => @config
27
+ ensure_valid_regions :regions => @opts[:region],
28
+ :config => @config
27
29
  ensure_metadata_in_upload_region :config => @config,
28
30
  :regions => @opts[:region]
31
+
32
+ @catalog.create_catalog_domain
33
+ unless @catalog.add_to_catalog :regions => @opts[:region],
34
+ :base => @opts[:base]
35
+ if @opts[:force]
36
+ @logger.warn "#{@opts[:name]} already exists."
37
+ else
38
+ @logger.warn "#{@opts[:name]} already exists, exiting."
39
+ exit 1
40
+ end
41
+ end
42
+
29
43
  @archive.setup :regions => @opts[:region],
30
44
  :bucket_prefix => @opts[:base]
31
45
  end
@@ -48,12 +62,13 @@ EOS
48
62
  region. For example: '-b test -r us-west-1 -r us-east-1' will create bucket test-us-west-1 \
49
63
  in us-west-1 and test-us-east-1 in us-east-1.", :type => :string
50
64
  opt :help, "Display Help"
65
+ opt :force, "Force setup even if entry already exists in catalog."
51
66
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
52
67
  :default => 'info'
53
68
  opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
54
69
  :default => 'us-west-1'
55
- opt :name, "Name of archive.", :type => :string
56
- opt :region, "AWS Region(s) to upload archive. \
70
+ opt :name, "Name of Heirloom.", :type => :string
71
+ opt :region, "AWS Region(s) to upload Heirloom. \
57
72
  Can be specified multiple times.", :type => :string,
58
73
  :multi => true,
59
74
  :default => 'us-west-1'
@@ -105,7 +105,6 @@ module Heirloom
105
105
  unless archive.buckets_exist? :regions => regions,
106
106
  :bucket_prefix => base
107
107
  logger.error "Required buckets for '#{base}' do not exist."
108
- logger.error "Run 'heirloom setup -h' for help setting up new region."
109
108
  exit 1
110
109
  end
111
110
  end
@@ -119,8 +118,7 @@ module Heirloom
119
118
  :config => config
120
119
 
121
120
  unless archive.domain_exists?
122
- logger.error "Metadata domain '#{name}' does not exist in '#{config.metadata_region}'."
123
- logger.error "Run 'heirloom setup -h' for help setting up new region."
121
+ logger.error "'#{name}' does not exist in '#{config.metadata_region}' catalog."
124
122
  exit 1
125
123
  end
126
124
  end
@@ -136,6 +134,17 @@ module Heirloom
136
134
  end
137
135
  end
138
136
 
137
+ def ensure_archive_domain_empty(args)
138
+ config = args[:config]
139
+ archive = args[:archive]
140
+ logger = config.logger
141
+
142
+ unless archive.count.zero?
143
+ logger.error "Not empty."
144
+ exit 1
145
+ end
146
+ end
147
+
139
148
  end
140
149
  end
141
150
  end
@@ -41,7 +41,7 @@ module Heirloom
41
41
  version Heirloom::VERSION
42
42
  banner <<-EOS
43
43
 
44
- Show archive.
44
+ Show Heirloom.
45
45
 
46
46
  Usage:
47
47
 
@@ -51,12 +51,12 @@ If -i is ommited, latest ID is displayed.
51
51
 
52
52
  EOS
53
53
  opt :help, "Display Help"
54
- opt :id, "ID of the archive to display.", :type => :string
54
+ opt :id, "ID of the Heirloom to display.", :type => :string
55
55
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
56
56
  :default => 'info'
57
57
  opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
58
58
  :default => 'us-west-1'
59
- opt :name, "Name of archive.", :type => :string
59
+ opt :name, "Name of Heirloom.", :type => :string
60
60
  opt :aws_access_key, "AWS Access Key ID", :type => :string,
61
61
  :short => :none
62
62
  opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
@@ -40,7 +40,7 @@ module Heirloom
40
40
  version Heirloom::VERSION
41
41
  banner <<-EOS
42
42
 
43
- Tag an archive with an attribute and value.
43
+ Tag an Heirloom with an attribute and value.
44
44
 
45
45
  Usage:
46
46
 
@@ -49,12 +49,12 @@ heirloom tag -n NAME -i ID -a ATTRIBUTE -u VALUE
49
49
  EOS
50
50
  opt :attribute, "Attribute to update.", :type => :string
51
51
  opt :help, "Display Help"
52
- opt :id, "ID of the archive to display.", :type => :string
52
+ opt :id, "ID of the Heirloom to tag.", :type => :string
53
53
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
54
54
  :default => 'info'
55
55
  opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
56
56
  :default => 'us-west-1'
57
- opt :name, "Name of archive.", :type => :string
57
+ opt :name, "Name of Heirloom.", :type => :string
58
58
  opt :value, "Value of attribute.", :type => :string,
59
59
  :short => 'u'
60
60
  opt :aws_access_key, "AWS Access Key ID", :type => :string,
@@ -0,0 +1,75 @@
1
+ module Heirloom
2
+ module CLI
3
+ class Teardown
4
+
5
+ include Heirloom::CLI::Shared
6
+
7
+ def initialize
8
+ @opts = read_options
9
+ @logger = HeirloomLogger.new :log_level => @opts[:level]
10
+ @config = load_config :logger => @logger,
11
+ :opts => @opts
12
+
13
+ ensure_valid_options :provided => @opts,
14
+ :required => [:name],
15
+ :config => @config
16
+
17
+ @catalog = Heirloom::Catalog.new :name => @opts[:name],
18
+ :config => @config
19
+ @archive = Archive.new :name => @opts[:name],
20
+ :config => @config
21
+
22
+ end
23
+
24
+ def teardown
25
+ ensure_domain_exists :name => @opts[:name],
26
+ :config => @config
27
+
28
+ ensure_archive_domain_empty :archive => @archive,
29
+ :config => @config
30
+
31
+ @regions = @catalog.regions
32
+ @base = @catalog.base
33
+
34
+ unless @opts[:keep_buckets]
35
+ @archive.delete_buckets :regions => @regions,
36
+ :bucket_prefix => @base
37
+ end
38
+
39
+ @archive.delete_domain
40
+ @catalog.delete_from_catalog
41
+ end
42
+
43
+ private
44
+
45
+ def read_options
46
+ Trollop::options do
47
+ version Heirloom::VERSION
48
+ banner <<-EOS
49
+
50
+ Teardown S3 buckets and SimpleDB domain for a given Heirloom name.
51
+
52
+ Usage:
53
+
54
+ heirloom teardown -n NAME
55
+
56
+ Note: All Heirlooms must be destroyed.
57
+
58
+ EOS
59
+ opt :help, "Display Help"
60
+ opt :level, "Log level [debug|info|warn|error].", :type => :string,
61
+ :default => 'info'
62
+ opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
63
+ :default => 'us-west-1'
64
+ opt :name, "Name of Heirloom.", :type => :string
65
+ opt :keep_buckets, "Do not delete S3 buckets."
66
+ opt :aws_access_key, "AWS Access Key ID", :type => :string,
67
+ :short => :none
68
+ opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
69
+ :short => :none
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -11,36 +11,34 @@ module Heirloom
11
11
  :opts => @opts
12
12
 
13
13
  ensure_valid_options :provided => @opts,
14
- :required => [:name, :id, :region,
15
- :base, :directory],
14
+ :required => [:name, :id, :directory],
16
15
  :config => @config
17
-
16
+ @catalog = Heirloom::Catalog.new :name => @opts[:name],
17
+ :config => @config
18
18
  @archive = Archive.new :name => @opts[:name],
19
19
  :id => @opts[:id],
20
20
  :config => @config
21
+ @regions = @catalog.regions
22
+ @base = @catalog.base
21
23
  end
22
24
 
23
25
  def upload
24
26
  ensure_valid_region :region => @opts[:metadata_region],
25
27
  :config => @config
26
- ensure_valid_regions :regions => @opts[:region],
27
- :config => @config
28
28
  ensure_domain_exists :name => @opts[:name],
29
29
  :config => @config
30
- ensure_buckets_exist :base => @opts[:base],
30
+ ensure_buckets_exist :base => @base,
31
31
  :name => @opts[:name],
32
- :regions => @opts[:region],
32
+ :regions => @regions,
33
33
  :config => @config
34
34
  ensure_directory :path => @opts[:directory],
35
35
  :config => @config
36
36
  ensure_valid_secret :secret => @opts[:secret],
37
37
  :config => @config
38
- ensure_metadata_in_upload_region :config => @config,
39
- :regions => @opts[:region]
40
38
 
41
- @archive.destroy :keep_domain => true if @archive.exists?
39
+ @archive.destroy if @archive.exists?
42
40
 
43
- build = @archive.build :base => @opts[:base],
41
+ build = @archive.build :base => @base,
44
42
  :directory => @opts[:directory],
45
43
  :exclude => @opts[:exclude],
46
44
  :git => @opts[:git],
@@ -51,8 +49,8 @@ module Heirloom
51
49
  exit 1
52
50
  end
53
51
 
54
- @archive.upload :bucket_prefix => @opts[:base],
55
- :regions => @opts[:region],
52
+ @archive.upload :bucket_prefix => @base,
53
+ :regions => @regions,
56
54
  :public_readable => @opts[:public],
57
55
  :file => build
58
56
  end
@@ -68,29 +66,22 @@ Upload a directory to Heirloom.
68
66
 
69
67
  Usage:
70
68
 
71
- heirloom upload -n NAME -i ID -b BASE -r REGION1 -r REGION2 -d DIRECTORY_TO_UPLOAD
69
+ heirloom upload -n NAME -i ID -d DIRECTORY_TO_UPLOAD
72
70
 
73
71
  EOS
74
- opt :base, "Base prefix which will be combined with region. \
75
- For example: -b 'test' -r 'us-west-1' will expect bucket 'test-us-west-1' \
76
- to be present", :type => :string
77
72
  opt :directory, "Source directory of build.", :type => :string
78
73
  opt :exclude, "File(s) or directorie(s) to exclude. \
79
74
  Can be specified multiple times.", :type => :string, :multi => true
80
- opt :git, "Read git commit information from directory and set as archive attributes."
75
+ opt :git, "Read git commit information from directory and set as Heirloom attributes."
81
76
  opt :help, "Display Help"
82
- opt :id, "ID for archive (when -g specified, assumed to be GIT sha).", :type => :string
77
+ opt :id, "ID for Heirloom (when -g specified, assumed to be GIT sha).", :type => :string
83
78
  opt :level, "Log level [debug|info|warn|error].", :type => :string,
84
79
  :default => 'info'
85
80
  opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
86
81
  :default => 'us-west-1'
87
- opt :name, "Name of archive.", :type => :string
88
- opt :public, "Set this archive as public readable?"
89
- opt :region, "Region(s) to upload archive. \
90
- Can be specified multiple times.", :type => :string,
91
- :multi => true,
92
- :default => 'us-west-1'
93
- opt :secret, "Encrypt the archive with given secret.", :type => :string
82
+ opt :name, "Name of Heirloom.", :type => :string
83
+ opt :public, "Set this Heirloom as public readable?"
84
+ opt :secret, "Encrypt the Heirloom with given secret.", :type => :string
94
85
  opt :aws_access_key, "AWS Access Key ID", :type => :string,
95
86
  :short => :none
96
87
  opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
data/lib/heirloom/cli.rb CHANGED
@@ -3,6 +3,7 @@ require 'trollop'
3
3
 
4
4
  require 'heirloom/cli/shared'
5
5
  require 'heirloom/cli/authorize'
6
+ require 'heirloom/cli/catalog'
6
7
  require 'heirloom/cli/upload'
7
8
  require 'heirloom/cli/setup'
8
9
  require 'heirloom/cli/list'
@@ -10,6 +11,7 @@ require 'heirloom/cli/show'
10
11
  require 'heirloom/cli/tag'
11
12
  require 'heirloom/cli/download'
12
13
  require 'heirloom/cli/destroy'
14
+ require 'heirloom/cli/teardown'
13
15
 
14
16
  module Heirloom
15
17
  module CLI
@@ -19,6 +21,8 @@ module Heirloom
19
21
  case cmd
20
22
  when 'authorize'
21
23
  CLI::Authorize.new.authorize
24
+ when 'catalog'
25
+ CLI::Catalog.new.list
22
26
  when 'destroy', 'delete'
23
27
  CLI::Destroy.new.destroy
24
28
  when 'download'
@@ -29,6 +33,8 @@ module Heirloom
29
33
  CLI::Setup.new.setup
30
34
  when 'show'
31
35
  CLI::Show.new.show
36
+ when 'teardown'
37
+ CLI::Teardown.new.teardown
32
38
  when 'update', 'tag'
33
39
  CLI::Tag.new.tag
34
40
  when 'build', 'upload'
@@ -37,7 +43,7 @@ module Heirloom
37
43
  puts Heirloom::VERSION
38
44
  else
39
45
  puts "Unkown command: '#{cmd}'." unless cmd == '-h'
40
- puts "heirloom [authorize|destroy|download|list|setup|show|tag|upload] OPTIONS"
46
+ puts "heirloom [authorize|catalog|destroy|download|list|setup|show|tag|teardown|upload] OPTIONS"
41
47
  puts "Append -h for help on specific command."
42
48
  end
43
49
  end
@@ -18,7 +18,7 @@ module Heirloom
18
18
 
19
19
  @local_build = Tempfile.new('archive.tar.gz').path
20
20
 
21
- @logger.info "Building Heirloom '#{@local_build}' from '#{@path}'."
21
+ @logger.debug "Building Heirloom '#{@local_build}' from '#{@path}'."
22
22
  @logger.debug "Excluding #{@exclude.to_s}."
23
23
  @logger.debug "Adding #{files_to_pack}."
24
24
 
@@ -1,3 +1,3 @@
1
1
  module Heirloom
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0rc1"
3
3
  end
data/lib/heirloom.rb CHANGED
@@ -1,11 +1,12 @@
1
- require "heirloom/config"
2
1
  require "heirloom/acl"
3
- require "heirloom/aws"
4
- require "heirloom/logger"
5
2
  require "heirloom/archive"
6
- require "heirloom/directory"
3
+ require "heirloom/aws"
4
+ require "heirloom/catalog"
7
5
  require "heirloom/cipher"
8
- require "heirloom/uploader"
9
- require "heirloom/downloader"
6
+ require "heirloom/config"
10
7
  require "heirloom/destroyer"
8
+ require "heirloom/directory"
9
+ require "heirloom/downloader"
10
+ require "heirloom/logger"
11
+ require "heirloom/uploader"
11
12
  require "heirloom/version"
data/spec/acl/s3_spec.rb CHANGED
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
  before do
5
5
  @config_mock = double 'config'
6
- @logger_mock = double 'logger'
7
- @config_mock.should_receive(:logger).and_return(@logger_mock)
6
+ @logger_stub = stub 'logger', :info => true, :debug => true
7
+ @config_mock.should_receive(:logger).and_return(@logger_stub)
8
8
 
9
9
  @s3 = Heirloom::ACL::S3.new :config => @config_mock,
10
10
  :region => 'us-west-1'
@@ -25,11 +25,6 @@ describe Heirloom do
25
25
  s3_mock.should_receive(:get_bucket_acl).with('bucket').
26
26
  and_return acls
27
27
 
28
- @logger_mock.should_receive(:info).
29
- with 'Authorizing acct1@test.com to s3://bucket/key-folder/key.tar.gz.'
30
- @logger_mock.should_receive(:info).
31
- with 'Authorizing acct2@test.com to s3://bucket/key-folder/key.tar.gz.'
32
-
33
28
  s3_mock.should_receive(:put_object_acl).
34
29
  with("bucket", "key-folder/key.tar.gz", {"Owner"=>{"DisplayName"=>"Brett", "ID"=>"123"}, "AccessControlList"=>[{"Grantee"=>{"EmailAddress"=>"acct1@test.com"}, "Permission"=>"READ"}, {"Grantee"=>{"EmailAddress"=>"acct2@test.com"}, "Permission"=>"READ"}, {"Grantee"=>{"DisplayName"=>"Brett", "ID"=>"123"}, "Permission"=>"FULL_CONTROL"}]})
35
30
 
@@ -4,15 +4,14 @@ describe Heirloom do
4
4
 
5
5
  before do
6
6
  @config_mock = double 'config'
7
- @logger_mock = double 'logger'
8
- @config_mock.should_receive(:logger).and_return(@logger_mock)
7
+ @logger_stub = stub 'logger', :info => true, :debug => true
8
+ @config_mock.should_receive(:logger).and_return @logger_stub
9
9
  @destroyer = Heirloom::Destroyer.new :config => @config_mock,
10
10
  :name => 'tim',
11
11
  :id => '123'
12
12
  end
13
13
 
14
14
  before do
15
- @logger_mock.stub :info => true
16
15
  @reader_mock = mock 'archive reader'
17
16
  @destroyer.stub :reader => @reader_mock
18
17
  @reader_mock.should_receive(:get_bucket).
@@ -31,23 +30,11 @@ describe Heirloom do
31
30
  :bucket => 'bucket-us-west-1'
32
31
  @sdb_mock = mock 'sdb'
33
32
  @destroyer.stub :sdb => @sdb_mock
34
- @sdb_mock.should_receive(:delete).with 'heirloom_tim', '123'
35
33
  end
36
34
 
37
35
  it "should destroy the given archive" do
38
- Kernel.should_receive(:sleep).with 3
39
- @sdb_mock.should_receive(:domain_empty?).with('heirloom_tim').
40
- and_return true
41
- @sdb_mock.should_receive(:delete_domain).with('heirloom_tim')
42
- @destroyer.destroy :regions => ['us-west-1'],
43
- :keep_domain => false
44
- end
45
-
46
- it "should destroy the given archive but keep the sbd domain" do
47
- @sdb_mock.should_receive(:domain_empty?).exactly(0).times
48
- @sdb_mock.should_receive(:delete_domain).exactly(0).times
49
- @destroyer.destroy :regions => ['us-west-1'],
50
- :keep_domain => true
36
+ @sdb_mock.should_receive(:delete).with 'heirloom_tim', '123'
37
+ @destroyer.destroy :regions => ['us-west-1']
51
38
  end
52
39
 
53
40
  end
@@ -12,7 +12,7 @@ describe Heirloom do
12
12
  sdb_mock = mock 'sdb'
13
13
  @lister.should_receive(:sdb).and_return sdb_mock
14
14
  sdb_mock.should_receive(:select).
15
- with("select * from heirloom_test123 where built_at > '2000-01-01T00:00:00.000Z' \
15
+ with("select * from `heirloom_test123` where built_at > '2000-01-01T00:00:00.000Z' \
16
16
  order by built_at desc limit 10").
17
17
  and_return( {'1' => 'one', '2' => 'two', '3' => 'three'} )
18
18
  @lister.list.should == ['1', '2', '3']
@@ -20,28 +20,28 @@ describe Heirloom do
20
20
 
21
21
  it "should show the item record" do
22
22
  @sdb_mock.should_receive(:select).
23
- with("select * from heirloom_tim where itemName() = '123'").
23
+ with("select * from `heirloom_tim` where itemName() = '123'").
24
24
  and_return( { '123' => { 'value' => [ 'details' ] } } )
25
25
  @reader.show.should == { 'value' => 'details' }
26
26
  end
27
27
 
28
28
  it "should return an empty hash if item does not exist" do
29
29
  @sdb_mock.should_receive(:select).
30
- with("select * from heirloom_tim where itemName() = '123'").
30
+ with("select * from `heirloom_tim` where itemName() = '123'").
31
31
  and_return({})
32
32
  @reader.show.should == {}
33
33
  end
34
34
 
35
35
  it "should return true if the record exists" do
36
36
  @sdb_mock.should_receive(:select).
37
- with("select * from heirloom_tim where itemName() = '123'").
37
+ with("select * from `heirloom_tim` where itemName() = '123'").
38
38
  and_return( { '123' => { 'value' => [ 'details' ] } } )
39
39
  @reader.exists?.should == true
40
40
  end
41
41
 
42
42
  it "should return false if the record does not exist" do
43
43
  @sdb_mock.should_receive(:select).
44
- with("select * from heirloom_tim where itemName() = '123'").
44
+ with("select * from `heirloom_tim` where itemName() = '123'").
45
45
  and_return({})
46
46
  @reader.exists?.should == false
47
47
  end
@@ -49,7 +49,7 @@ describe Heirloom do
49
49
  it "should return the bucket if it exists" do
50
50
  @sdb_mock.should_receive(:select).
51
51
  exactly(3).times.
52
- with("select * from heirloom_tim where itemName() = '123'").
52
+ with("select * from `heirloom_tim` where itemName() = '123'").
53
53
  and_return( { '123' =>
54
54
  { 'us-west-1-s3-url' =>
55
55
  [ 's3://the-bucket/the-buck/the-key' ]
@@ -61,7 +61,7 @@ describe Heirloom do
61
61
  it "should return nil if the key does not exist" do
62
62
  @sdb_mock.should_receive(:select).
63
63
  exactly(1).times.
64
- with("select * from heirloom_tim where itemName() = '123'").
64
+ with("select * from `heirloom_tim` where itemName() = '123'").
65
65
  and_return( { } )
66
66
  @reader.get_key(:region => 'us-west-1').should == nil
67
67
  end
@@ -69,7 +69,7 @@ describe Heirloom do
69
69
  it "should return nil if the bucket does not exist" do
70
70
  @sdb_mock.should_receive(:select).
71
71
  exactly(1).times.
72
- with("select * from heirloom_tim where itemName() = '123'").
72
+ with("select * from `heirloom_tim` where itemName() = '123'").
73
73
  and_return( { } )
74
74
  @reader.get_bucket(:region => 'us-west-1').should == nil
75
75
  end
@@ -77,7 +77,7 @@ describe Heirloom do
77
77
  it "should return the key if it exists" do
78
78
  @sdb_mock.should_receive(:select).
79
79
  exactly(6).times.
80
- with("select * from heirloom_tim where itemName() = '123'").
80
+ with("select * from `heirloom_tim` where itemName() = '123'").
81
81
  and_return( { '123' =>
82
82
  { 'us-west-1-s3-url' =>
83
83
  ['s3://the-url/the-bucket/the-key']
@@ -89,7 +89,7 @@ describe Heirloom do
89
89
  it "should return the regions the archive has been uploaded to" do
90
90
  @sdb_mock.should_receive(:select).
91
91
  exactly(1).times.
92
- with("select * from heirloom_tim where itemName() = '123'").
92
+ with("select * from `heirloom_tim` where itemName() = '123'").
93
93
  and_return( { '123' =>
94
94
  { 'us-west-1-s3-url' =>
95
95
  ['s3://the-url-us-west-1/the-bucket/the-key'],