pogo 2.31.2 → 2.32.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,8 +16,19 @@ module Heroku::Command
16
16
  "PGBACKUPS_URL" => "https://ip:password@pgbackups.heroku.com/client"
17
17
  }
18
18
  )
19
+ @pgbackups.stub :app_attachments => mock_attachments
19
20
  end
20
21
 
22
+ let(:mock_attachments) {
23
+ [
24
+ Heroku::Helpers::HerokuPostgresql::Attachment.new({
25
+ 'config_var' => 'HEROKU_POSTGRESQL_IVORY',
26
+ 'resource' => {'name' => 'softly-mocking-123',
27
+ 'value' => 'postgres://database',
28
+ 'type' => 'heroku-postgresql:baku' }})
29
+ ]
30
+ }
31
+
21
32
  after do
22
33
  api.delete_app("myapp")
23
34
  end
@@ -42,6 +53,13 @@ STDOUT
42
53
  end
43
54
 
44
55
  describe "single backup" do
56
+ let(:from_name) { "FROM_NAME" }
57
+ let(:from_url) { "postgres://from/bar" }
58
+ let(:attachment) { double('attachment', :display_name => from_name, :url => from_url ) }
59
+ before do
60
+ @pgbackups.stub!(:hpg_resolve).and_return(attachment)
61
+ end
62
+
45
63
  it "gets the url for the latest backup if nothing is specified" do
46
64
  stub_core
47
65
  stub_pgbackups.get_latest_backup.returns({"public_url" => "http://latest/backup.dump"})
@@ -70,11 +88,9 @@ STDOUT
70
88
  end
71
89
 
72
90
  it "should capture a backup when requested" do
73
- from_name, from_url = "FROM_NAME", "postgres://from/bar"
74
91
  backup_obj = {'to_url' => "s3://bucket/userid/b001.dump"}
75
92
 
76
93
  @pgbackups.stub!(:args).and_return([])
77
- @pgbackups.stub!(:hpg_resolve).and_return([from_name, from_url])
78
94
  @pgbackups.stub!(:transfer!).with(from_url, from_name, nil, "BACKUP", {:expire => nil}).and_return(backup_obj)
79
95
  @pgbackups.stub!(:poll_transfer!).with(backup_obj).and_return(backup_obj)
80
96
 
@@ -82,11 +98,9 @@ STDOUT
82
98
  end
83
99
 
84
100
  it "should send expiration flag to client if specified on args" do
85
- from_name, from_url = "FROM_NAME", "postgres://from/bar"
86
101
  backup_obj = {'to_url' => "s3://bucket/userid/b001.dump"}
87
102
 
88
103
  @pgbackups.stub!(:options).and_return({:expire => true})
89
- @pgbackups.stub!(:hpg_resolve).and_return([from_name, from_url])
90
104
  @pgbackups.stub!(:transfer!).with(from_url, from_name, nil, "BACKUP", {:expire => true}).and_return(backup_obj)
91
105
  @pgbackups.stub!(:poll_transfer!).with(backup_obj).and_return(backup_obj)
92
106
 
@@ -136,6 +150,12 @@ STDERR
136
150
  stub_core
137
151
  stub_pgbackups.create_transfer.returns(@backup_obj)
138
152
  stub_pgbackups.get_transfer.returns(@backup_obj)
153
+
154
+ any_instance_of(Heroku::Command::Pgbackups) do |pgbackups|
155
+ stub(pgbackups).app_attachments.returns(
156
+ mock_attachments
157
+ )
158
+ end
139
159
  end
140
160
 
141
161
  it 'aborts on a generic error' do
@@ -185,6 +205,7 @@ STDOUT
185
205
  end
186
206
 
187
207
  context "restore" do
208
+ let(:attachment) { double('attachment', :display_name => 'someconfigvar', :url => 'postgres://fromhost/database') }
188
209
  before do
189
210
  from_name, from_url = "FROM_NAME", "postgres://fromhost/database"
190
211
 
@@ -226,12 +247,13 @@ STDOUT
226
247
  @pgbackups.restore
227
248
  end
228
249
 
250
+
229
251
  it "should restore the named backup" do
230
252
  name = "backupname"
231
253
  args = ['DATABASE', name]
232
254
  @pgbackups.stub(:args).and_return(args)
233
255
  @pgbackups.stub(:shift_argument).and_return(*args)
234
- @pgbackups.stub(:hpg_resolve).and_return([name])
256
+ @pgbackups.stub(:hpg_resolve).and_return(attachment)
235
257
  @pgbackups_client.should_receive(:get_backup).with(name).and_return(@backup_obj)
236
258
  @pgbackups.restore
237
259
  end
@@ -240,7 +262,7 @@ STDOUT
240
262
  args = ['db_name_gets_shifted_out_in_resolve_db', 'http://external/file.dump']
241
263
  @pgbackups.stub(:args).and_return(args)
242
264
  @pgbackups.stub(:shift_argument).and_return(*args)
243
- @pgbackups.stub(:hpg_resolve).and_return(["name", "url"])
265
+ @pgbackups.stub(:hpg_resolve).and_return(attachment)
244
266
  @pgbackups_client.should_not_receive(:get_backup)
245
267
  @pgbackups_client.should_not_receive(:get_latest_backup)
246
268
  @pgbackups.restore
@@ -117,12 +117,12 @@ describe Heroku::Command do
117
117
  end
118
118
 
119
119
  it "shows Internal Server Error when the response doesn't contain a XML or JSON" do
120
- Heroku::Command.extract_error('<h1>HTTP 500</h1>').should == "Internal server error.\nRun 'heroku status' to check for known platform issues."
120
+ Heroku::Command.extract_error('<h1>HTTP 500</h1>').should == "Internal server error.\nRun `heroku status` to check for known platform issues."
121
121
  end
122
122
 
123
123
  it "shows Internal Server Error when the response is not plain text" do
124
124
  response = FakeResponse.new(:body => "Foobar", :headers => { :content_type => "application/xml" })
125
- Heroku::Command.extract_error(response).should == "Internal server error.\nRun 'heroku status' to check for known platform issues."
125
+ Heroku::Command.extract_error(response).should == "Internal server error.\nRun `heroku status` to check for known platform issues."
126
126
  end
127
127
 
128
128
  it "allows a block to redefine the default error" do
@@ -6,7 +6,9 @@ include Heroku::Helpers::HerokuPostgresql
6
6
  describe Heroku::Helpers::HerokuPostgresql do
7
7
 
8
8
  before do
9
+ subject.forget_config!
9
10
  subject.stub(:app_config_vars) { app_config_vars }
11
+ subject.stub(:app_attachments) { app_attachments }
10
12
  end
11
13
 
12
14
  let(:app_config_vars) do
@@ -18,92 +20,108 @@ describe Heroku::Helpers::HerokuPostgresql do
18
20
  }
19
21
  end
20
22
 
23
+ let(:app_attachments) {
24
+ [ Attachment.new({ 'config_var' => 'HEROKU_POSTGRESQL_IVORY_URL',
25
+ 'resource' => {'name' => 'softly-mocking-123',
26
+ 'value' => 'postgres://default',
27
+ 'type' => 'heroku-postgresql:baku' }}),
28
+ Attachment.new({ 'config_var' => 'HEROKU_POSTGRESQL_BLACK_URL',
29
+ 'resource' => {'name' => 'quickly-yelling-2421',
30
+ 'value' => 'postgres://black',
31
+ 'type' => 'heroku-postgresql:zilla' }})
32
+ ]
33
+ }
34
+
21
35
  it "resolves DATABASE" do
22
- subject.hpg_resolve('DATABASE').should == [
23
- "HEROKU_POSTGRESQL_IVORY (DATABASE_URL)",
24
- "postgres://default"
25
- ]
36
+ att = subject.hpg_resolve('DATABASE')
37
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
38
+ att.url.should == "postgres://default"
26
39
  end
27
40
 
28
41
  it "resolves SHARED_DATABASE" do
29
- subject.hpg_resolve('SHARED_DATABASE').should == [
30
- "SHARED_DATABASE",
31
- "postgres://shared"
32
- ]
42
+ att = subject.hpg_resolve('SHARED_DATABASE')
43
+ att.display_name.should == "SHARED_DATABASE"
44
+ att.url.should == "postgres://shared"
33
45
  end
34
46
 
35
47
  it "resolves default using NAME" do
36
- subject.hpg_resolve("IVORY").should == [
37
- "HEROKU_POSTGRESQL_IVORY (DATABASE_URL)",
38
- "postgres://default"
39
- ]
48
+ att = subject.hpg_resolve('IVORY')
49
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
50
+ att.url.should == "postgres://default"
40
51
  end
41
52
 
42
53
  it "resolves non-default using NAME" do
43
- subject.hpg_resolve("BLACK").should == [
44
- "HEROKU_POSTGRESQL_BLACK",
45
- "postgres://black"
46
- ]
54
+ att = subject.hpg_resolve('BLACK')
55
+ att.display_name.should == "HEROKU_POSTGRESQL_BLACK_URL"
56
+ att.url.should == "postgres://black"
47
57
  end
48
58
 
49
59
  it "resolves default using NAME_URL" do
50
- subject.hpg_resolve("IVORY_URL").should == [
51
- "HEROKU_POSTGRESQL_IVORY (DATABASE_URL)",
52
- "postgres://default"
53
- ]
60
+ att = subject.hpg_resolve('IVORY_URL')
61
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
62
+ att.url.should == "postgres://default"
54
63
  end
55
64
 
56
65
  it "resolves non-default using NAME_URL" do
57
- subject.hpg_resolve("BLACK_URL").should == [
58
- "HEROKU_POSTGRESQL_BLACK",
59
- "postgres://black"
60
- ]
66
+ att = subject.hpg_resolve('BLACK_URL')
67
+ att.display_name.should == "HEROKU_POSTGRESQL_BLACK_URL"
68
+ att.url.should == "postgres://black"
61
69
  end
62
70
 
63
71
  it "resolves default using lowercase" do
64
- subject.hpg_resolve("ivory").should == [
65
- "HEROKU_POSTGRESQL_IVORY (DATABASE_URL)",
66
- "postgres://default"
67
- ]
72
+ att = subject.hpg_resolve('ivory')
73
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
74
+ att.url.should == "postgres://default"
68
75
  end
69
76
 
70
77
  it "resolves non-default using lowercase" do
71
- subject.hpg_resolve("black").should == [
72
- "HEROKU_POSTGRESQL_BLACK",
73
- "postgres://black"
74
- ]
78
+ att = subject.hpg_resolve('black')
79
+ att.display_name.should == "HEROKU_POSTGRESQL_BLACK_URL"
80
+ att.url.should == "postgres://black"
81
+ end
82
+
83
+ it "resolves non-default using part of name" do
84
+ att = subject.hpg_resolve('bla')
85
+ att.display_name.should == "HEROKU_POSTGRESQL_BLACK_URL"
86
+ att.url.should == "postgres://black"
75
87
  end
76
88
 
77
89
  it "throws an error if it doesnt exist" do
78
- subject.should_receive(:error).with("Unknown database: VIOLET. Valid options are: DATABASE, HEROKU_POSTGRESQL_BLACK, HEROKU_POSTGRESQL_IVORY, SHARED_DATABASE")
90
+ subject.should_receive(:error).with("Unknown database: violet. Valid options are: DATABASE_URL, HEROKU_POSTGRESQL_BLACK_URL, HEROKU_POSTGRESQL_IVORY_URL, SHARED_DATABASE")
79
91
  subject.hpg_resolve("violet")
80
92
  end
81
93
 
82
94
  context "default" do
83
95
 
84
96
  it "errors if there is no default" do
85
- subject.should_receive(:error).with("Unknown database. Valid options are: DATABASE, HEROKU_POSTGRESQL_BLACK, HEROKU_POSTGRESQL_IVORY, SHARED_DATABASE")
97
+ subject.should_receive(:error).with("Unknown database. Valid options are: DATABASE_URL, HEROKU_POSTGRESQL_BLACK_URL, HEROKU_POSTGRESQL_IVORY_URL, SHARED_DATABASE")
86
98
  subject.hpg_resolve(nil)
87
99
  end
88
100
 
89
- it "uses the default if nothing specified" do
90
- subject.hpg_resolve(nil, "DATABASE_URL").should == [
91
- "HEROKU_POSTGRESQL_IVORY (DATABASE_URL)",
92
- "postgres://default"
93
- ]
101
+ it "uses the default if nothing(nil) specified" do
102
+ att = subject.hpg_resolve(nil, "DATABASE_URL")
103
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
104
+ att.url.should == "postgres://default"
94
105
  end
95
106
 
96
- end
107
+ it "uses the default if nothing(empty) specified" do
108
+ att = subject.hpg_resolve('', "DATABASE_URL")
109
+ att.display_name.should == "HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)"
110
+ att.url.should == "postgres://default"
111
+ end
97
112
 
98
- context "uri" do
113
+ it 'throws an error if given an empty string and asked for the default and there is no default' do
114
+ app_config_vars.delete 'DATABASE_URL'
115
+ subject.should_receive(:error).with("Unknown database. Valid options are: HEROKU_POSTGRESQL_BLACK_URL, HEROKU_POSTGRESQL_IVORY_URL, SHARED_DATABASE")
116
+ att = subject.hpg_resolve('', "DATABASE_URL")
117
+ end
99
118
 
100
- it "returns the uri directly" do
101
- subject.hpg_resolve('postgres://uri', nil).should == [
102
- nil,
103
- 'postgres://uri'
104
- ]
119
+ it 'throws an error if given an empty string and asked for the default and the default doesnt match' do
120
+ app_config_vars['DATABASE_URL'] = 'something different'
121
+ subject.should_receive(:error).with("Unknown database. Valid options are: HEROKU_POSTGRESQL_BLACK_URL, HEROKU_POSTGRESQL_IVORY_URL, SHARED_DATABASE")
122
+ att = subject.hpg_resolve('', "DATABASE_URL")
105
123
  end
106
124
 
107
- end
108
125
 
126
+ end
109
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pogo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.31.2
4
+ version: 2.32.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku-api
@@ -142,6 +142,7 @@ files:
142
142
  - lib/heroku/deprecated.rb
143
143
  - lib/heroku/deprecated/help.rb
144
144
  - lib/heroku/distribution.rb
145
+ - lib/heroku/excon.rb
145
146
  - lib/heroku/helpers.rb
146
147
  - lib/heroku/helpers/heroku_postgresql.rb
147
148
  - lib/heroku/plugin.rb
@@ -193,9 +194,9 @@ files:
193
194
  homepage: http://pogoapp.com/
194
195
  licenses:
195
196
  - MIT
196
- post_install_message: ! ' ! Thanks for trying the Pogoapp beta!
197
-
198
- '
197
+ post_install_message: ! " ! The `heroku` gem has been deprecated and replaced with
198
+ the Heroku Toolbelt.\n ! Download and install from: https://toolbelt.heroku.com\n
199
+ ! For API access, see: https://github.com/heroku/heroku.rb\n"
199
200
  rdoc_options: []
200
201
  require_paths:
201
202
  - lib