fourchette 0.1.3 → 0.1.4
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/lib/fourchette/pgbackups.rb +4 -4
- data/lib/fourchette/version.rb +1 -1
- data/spec/lib/fourchette/pgbackups_spec.rb +78 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f6554bcc58aaa634fad3e12d9ed741810c97c39
|
4
|
+
data.tar.gz: b8ee77e9b07d31c6249a6456533709c13a768293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046c9ecb6815f472dee8af7641171c3166b2b9f2eb133f5fbc6dff456f271e59813c7c85e95fd02be2f86302cfb1486597f944e5e34cd71025d12285d841cec5
|
7
|
+
data.tar.gz: 2927f472f67fa7fc3f7d5f14a707e4ae403001e523a188abba7b8c822662fe3d3d0e427e410e75e16ddbd77fc4fd9f506478ce08e5f026cb262fb5af95bf3295
|
data/lib/fourchette/pgbackups.rb
CHANGED
@@ -20,16 +20,16 @@ class Fourchette::Pgbackups
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def ensure_pgbackups_is_present(heroku_app_name)
|
23
|
-
unless existing_backups?
|
23
|
+
unless existing_backups?(heroku_app_name)
|
24
24
|
logger.info "Adding pgbackups to #{heroku_app_name}"
|
25
25
|
@heroku.client.addon.create(heroku_app_name, { plan: 'pgbackups' })
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def existing_backups?
|
30
|
-
@heroku.client.addon.list(heroku_app_name).
|
29
|
+
def existing_backups?(heroku_app_name)
|
30
|
+
@heroku.client.addon.list(heroku_app_name).any? do |addon|
|
31
31
|
addon['name'] == 'pgbackups'
|
32
|
-
end
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def pg_details_for(app_name)
|
data/lib/fourchette/version.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fourchette::Pgbackups do
|
4
|
+
describe '#copy' do
|
5
|
+
let(:from_app_name) { 'awesome app' }
|
6
|
+
let(:to_app_name) { 'awesomer app!' }
|
7
|
+
let(:pg_backup) { Fourchette::Pgbackups.new }
|
8
|
+
let(:heroku) { instance_double(Fourchette::Heroku) }
|
9
|
+
|
10
|
+
let(:config_vars_from) do
|
11
|
+
{ 'HEROKU_POSTGRESQL_FROM_URL' => 'postgres://from...',
|
12
|
+
'PGBACKUPS_URL' => 'postgres://frombackup...' }
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:config_vars_to) do
|
16
|
+
{ 'HEROKU_POSTGRESQL_TO_URL' => 'postgres://to...',
|
17
|
+
'PGBACKUPS_URL' => 'postgres://tobackup...' }
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(Fourchette::Heroku).to receive(:new).and_return(heroku)
|
22
|
+
|
23
|
+
allow(heroku)
|
24
|
+
.to receive_message_chain(:client, :addon, :list)
|
25
|
+
.and_return([{ 'name' => addon_name }])
|
26
|
+
|
27
|
+
allow(heroku)
|
28
|
+
.to receive(:config_vars)
|
29
|
+
.with(from_app_name)
|
30
|
+
.and_return(config_vars_from)
|
31
|
+
|
32
|
+
allow(heroku)
|
33
|
+
.to receive(:config_vars)
|
34
|
+
.with(to_app_name)
|
35
|
+
.and_return(config_vars_to)
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when Pgbackups addon is enabled' do
|
39
|
+
let(:addon_name) { 'pgbackups' }
|
40
|
+
let(:backup) { instance_double(Heroku::Client::Pgbackups) }
|
41
|
+
|
42
|
+
it 'launches a PG backup from origin app to destination one' do
|
43
|
+
expect(Heroku::Client::Pgbackups)
|
44
|
+
.to receive(:new)
|
45
|
+
.with(config_vars_from['PGBACKUPS_URL'] + '/api')
|
46
|
+
.and_return(backup)
|
47
|
+
|
48
|
+
expect(backup).to receive(:create_transfer).with(
|
49
|
+
config_vars_from['HEROKU_POSTGRESQL_FROM_URL'],
|
50
|
+
'HEROKU_POSTGRESQL_FROM_URL',
|
51
|
+
config_vars_to['HEROKU_POSTGRESQL_TO_URL'],
|
52
|
+
'HEROKU_POSTGRESQL_TO_URL'
|
53
|
+
)
|
54
|
+
|
55
|
+
pg_backup.copy(from_app_name, to_app_name)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when Pgbackups addon is not enabled' do
|
60
|
+
let(:addon_name) { 'addon' }
|
61
|
+
|
62
|
+
it 'enables Pgbackups addon and launches a PG backup' do
|
63
|
+
expect(heroku)
|
64
|
+
.to receive_message_chain(:client, :addon, :create)
|
65
|
+
.with(to_app_name, { plan: 'pgbackups' })
|
66
|
+
|
67
|
+
expect(heroku)
|
68
|
+
.to receive_message_chain(:client, :addon, :create)
|
69
|
+
.with(from_app_name, { plan: 'pgbackups' })
|
70
|
+
|
71
|
+
expect(Heroku::Client::Pgbackups)
|
72
|
+
.to receive_message_chain(:new, :create_transfer)
|
73
|
+
|
74
|
+
pg_backup.copy(from_app_name, to_app_name)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fourchette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Boily
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -276,6 +276,7 @@ files:
|
|
276
276
|
- spec/lib/fourchette/github_spec.rb
|
277
277
|
- spec/lib/fourchette/heroku_spec.rb
|
278
278
|
- spec/lib/fourchette/logger_spec.rb
|
279
|
+
- spec/lib/fourchette/pgbackups_spec.rb
|
279
280
|
- spec/lib/fourchette/pull_request_spec.rb
|
280
281
|
- spec/lib/fourchette/tarball_spec.rb
|
281
282
|
- spec/lib/web/hooks_spec.rb
|
@@ -319,6 +320,7 @@ test_files:
|
|
319
320
|
- spec/lib/fourchette/github_spec.rb
|
320
321
|
- spec/lib/fourchette/heroku_spec.rb
|
321
322
|
- spec/lib/fourchette/logger_spec.rb
|
323
|
+
- spec/lib/fourchette/pgbackups_spec.rb
|
322
324
|
- spec/lib/fourchette/pull_request_spec.rb
|
323
325
|
- spec/lib/fourchette/tarball_spec.rb
|
324
326
|
- spec/lib/web/hooks_spec.rb
|