stratocumulus 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,25 @@
1
1
  # encoding: UTF-8
2
- require 'simplecov'
3
- require 'coveralls'
4
- require 'stringio'
2
+ require "simplecov"
3
+ require "codeclimate-test-reporter"
4
+ require "stringio"
5
5
 
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
7
7
  SimpleCov::Formatter::HTMLFormatter,
8
- Coveralls::SimpleCov::Formatter
9
- ]
8
+ CodeClimate::TestReporter::Formatter,
9
+ ])
10
10
 
11
11
  SimpleCov.start do
12
12
  minimum_coverage 100
13
13
  end
14
14
 
15
- require 'bundler/setup'
15
+ require "bundler/setup"
16
16
  Bundler.setup
17
17
 
18
- require 'stratocumulus'
18
+ require "stratocumulus"
19
19
  Fog.mock!
20
20
 
21
21
  RSpec.configure do |config|
22
- config.default_formatter = 'doc' if config.files_to_run.one?
22
+ config.default_formatter = "doc" if config.files_to_run.one?
23
23
 
24
24
  config.profile_examples = 10
25
25
  config.order = :random
@@ -1,17 +1,17 @@
1
1
  # encoding: UTF-8
2
- require 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe Stratocumulus::Cli do
5
- describe '#backups' do
5
+ describe "#backups" do
6
6
  let(:runner) { double }
7
7
 
8
- it 'calls the runner with the path' do
8
+ it "calls the runner with the path" do
9
9
  expect(Stratocumulus::Runner).to receive(:new)
10
- .with('/path/to/config.yml').and_return(runner)
10
+ .with("/path/to/config.yml").and_return(runner)
11
11
 
12
12
  expect(runner).to receive(:run)
13
13
 
14
- subject.backup '/path/to/config.yml'
14
+ subject.backup "/path/to/config.yml"
15
15
  end
16
16
  end
17
17
  end
@@ -1,8 +1,7 @@
1
1
  # encoding: UTF-8
2
- require 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe Stratocumulus::Database do
5
-
6
5
  subject do
7
6
  described_class.build(config)
8
7
  end
@@ -11,111 +10,109 @@ describe Stratocumulus::Database do
11
10
 
12
11
  let(:base_config) do
13
12
  {
14
- 'name' => 'stratocumulus_test',
15
- 'type' => type
13
+ "name" => "stratocumulus_test",
14
+ "type" => type,
16
15
  }
17
16
  end
18
17
 
19
- let(:type) { 'mysql' }
18
+ let(:type) { "mysql" }
20
19
 
21
20
  before do
22
21
  allow_any_instance_of(Stratocumulus::Database).to(
23
- receive(:system).and_return(true)
22
+ receive(:system).and_return(true),
24
23
  )
25
24
  end
26
25
 
27
- describe '.new' do
28
- context 'the database type is not supported' do
29
- let(:config) { base_config.merge('type' => 'nosqlioid') }
26
+ describe ".new" do
27
+ context "the database type is not supported" do
28
+ let(:config) { base_config.merge("type" => "nosqlioid") }
30
29
 
31
- it 'thows an error unless the type is supported' do
30
+ it "thows an error unless the type is supported" do
32
31
  expect { subject }.to raise_error(
33
32
  RuntimeError,
34
- 'nosqlioid is not a supported database'
33
+ "nosqlioid is not a supported database",
35
34
  )
36
35
  end
37
36
  end
38
37
 
39
- context 'mysql' do
40
- it 'throws an error if mysqldump is not installed' do
38
+ context "mysql" do
39
+ it "throws an error if mysqldump is not installed" do
41
40
  allow_any_instance_of(Stratocumulus::Database).to(
42
- receive(:system).with(/which mysqldump/)
41
+ receive(:system).with(/which mysqldump/),
43
42
  )
44
43
 
45
44
  expect { subject }.to raise_error(
46
45
  RuntimeError,
47
- 'mysqldump not available'
46
+ "mysqldump not available",
48
47
  )
49
48
  end
50
49
  end
51
50
 
52
- context 'postgresql' do
53
- let(:type) { 'psql' }
51
+ context "postgresql" do
52
+ let(:type) { "psql" }
54
53
 
55
- it 'throws an error if pg_dump is not installed' do
54
+ it "throws an error if pg_dump is not installed" do
56
55
  allow_any_instance_of(Stratocumulus::Database)
57
- .to receive(:system).with(/which pg_dump/)
56
+ .to receive(:system).with(/which pg_dump/)
58
57
 
59
58
  expect { subject }.to raise_error(
60
59
  RuntimeError,
61
- 'pg_dump not available'
60
+ "pg_dump not available",
62
61
  )
63
62
  end
64
63
  end
65
64
 
66
- it 'throws an error if gzip is not installed' do
65
+ it "throws an error if gzip is not installed" do
67
66
  allow_any_instance_of(Stratocumulus::Database)
68
67
  .to receive(:system).with(/which gzip/)
69
68
 
70
69
  expect { subject }.to raise_error(
71
70
  RuntimeError,
72
- 'gzip not available'
71
+ "gzip not available",
73
72
  )
74
73
  end
75
74
 
76
- context 'when no database name is provided' do
77
-
75
+ context "when no database name is provided" do
78
76
  let(:config) do
79
- { 'type' => 'mysql' }
77
+ { "type" => "mysql" }
80
78
  end
81
79
 
82
- it 'throws an error' do
80
+ it "throws an error" do
83
81
  expect { subject }.to raise_error(
84
82
  RuntimeError,
85
- 'database name not specified'
83
+ "database name not specified",
86
84
  )
87
85
  end
88
-
89
86
  end
90
87
  end
91
88
 
92
- describe '#filename' do
93
- it 'calculates a filename based on the name and timestamp' do
94
- timestamp = Time.now.utc.strftime('%Y%m%d%H%M')
89
+ describe "#filename" do
90
+ it "calculates a filename based on the name and timestamp" do
91
+ timestamp = Time.now.utc.strftime("%Y%m%d%H%M")
95
92
  filename = "stratocumulus_test/stratocumulus_test.#{timestamp}.sql.gz"
96
93
  expect(subject.filename).to eq filename
97
94
  end
98
95
 
99
- it 'stays the same for an instance even if time moves on' do
96
+ it "stays the same for an instance even if time moves on" do
100
97
  filename = subject.filename
101
98
  allow(Time).to receive(:now).and_return(Time.now + 60 * 60 * 26)
102
99
  expect(subject.filename).to eq filename
103
100
  end
104
101
  end
105
102
 
106
- describe '#success?' do
107
- describe 'the dump fails' do
108
- subject { FailingDatabase.new('name' => 'test_database') }
103
+ describe "#success?" do
104
+ describe "the dump fails" do
105
+ subject { FailingDatabase.new("name" => "test_database") }
109
106
 
110
- it 'returns false' do
107
+ it "returns false" do
111
108
  expect(subject).to_not be_success
112
109
  end
113
110
  end
114
111
 
115
- describe 'the dump is sucessfull' do
116
- subject { SucessDatabase.new('name' => 'test_database') }
112
+ describe "the dump is sucessfull" do
113
+ subject { SucessDatabase.new("name" => "test_database") }
117
114
 
118
- it 'returns false' do
115
+ it "returns false" do
119
116
  expect(subject).to be_success
120
117
  end
121
118
  end
@@ -123,13 +120,13 @@ describe Stratocumulus::Database do
123
120
 
124
121
  class SucessDatabase < described_class
125
122
  def command
126
- 'echo boo'
123
+ "echo boo"
127
124
  end
128
125
  end
129
126
 
130
127
  class FailingDatabase < described_class
131
128
  def command
132
- 'exit 127'
129
+ "exit 127"
133
130
  end
134
131
  end
135
132
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
- require 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe Stratocumulus::MySQL do
5
5
  subject do
@@ -7,96 +7,96 @@ describe Stratocumulus::MySQL do
7
7
  end
8
8
 
9
9
  let(:config) do
10
- { 'name' => 'stratocumulus_test' }
10
+ { "name" => "stratocumulus_test" }
11
11
  end
12
12
 
13
- describe '#dependencies' do
13
+ describe "#dependencies" do
14
14
  specify do
15
15
  expect(subject.dependencies).to eq %w(gzip mysqldump)
16
16
  end
17
17
  end
18
18
 
19
- describe '#command' do
20
- context 'default' do
21
- it 'generates the dump command with sensible defaults' do
19
+ describe "#command" do
20
+ context "default" do
21
+ it "generates the dump command with sensible defaults" do
22
22
  expect(subject.command).to eq(
23
- 'mysqldump --single-transaction -uroot stratocumulus_test'
23
+ "mysqldump --single-transaction -uroot stratocumulus_test",
24
24
  )
25
25
  end
26
26
  end
27
27
 
28
- context 'with the password set' do
28
+ context "with the password set" do
29
29
  let(:config) do
30
30
  {
31
- 'name' => 'stratocumulus_test',
32
- 'password' => 'seecrit'
31
+ "name" => "stratocumulus_test",
32
+ "password" => "seecrit",
33
33
  }
34
34
  end
35
35
 
36
- it 'generates the dump command with a default host' do
36
+ it "generates the dump command with a default host" do
37
37
  expect(subject.command).to eq(
38
- 'mysqldump --single-transaction -uroot -pseecrit stratocumulus_test'
38
+ "mysqldump --single-transaction -uroot -pseecrit stratocumulus_test",
39
39
  )
40
40
  end
41
41
  end
42
42
 
43
- context 'with the port set' do
43
+ context "with the port set" do
44
44
  let(:config) do
45
45
  {
46
- 'name' => 'stratocumulus_test',
47
- 'port' => 13_306
46
+ "name" => "stratocumulus_test",
47
+ "port" => 13_306,
48
48
  }
49
49
  end
50
50
 
51
- it 'generates the dump command with a default host' do
51
+ it "generates the dump command with a default host" do
52
52
  expect(subject.command).to eq(
53
- 'mysqldump --single-transaction -uroot -hlocalhost -P13306 stratocumulus_test' # rubocop:disable Style/LineLength
53
+ "mysqldump --single-transaction -uroot -hlocalhost -P13306 stratocumulus_test" # rubocop:disable Metrics/LineLength
54
54
  )
55
55
  end
56
56
  end
57
57
 
58
- context 'with the host set' do
58
+ context "with the host set" do
59
59
  let(:config) do
60
60
  {
61
- 'name' => 'stratocumulus_test',
62
- 'host' => 'db.example.com'
61
+ "name" => "stratocumulus_test",
62
+ "host" => "db.example.com",
63
63
  }
64
64
  end
65
65
 
66
- it 'generates the dump command with a default port' do
66
+ it "generates the dump command with a default port" do
67
67
  expect(subject.command).to eq(
68
- 'mysqldump --single-transaction -uroot -hdb.example.com -P3306 stratocumulus_test' # rubocop:disable Style/LineLength
68
+ "mysqldump --single-transaction -uroot -hdb.example.com -P3306 stratocumulus_test" # rubocop:disable Metrics/LineLength
69
69
  )
70
70
  end
71
71
  end
72
72
 
73
- context 'with the port and host set' do
73
+ context "with the port and host set" do
74
74
  let(:config) do
75
75
  {
76
- 'name' => 'stratocumulus_test',
77
- 'port' => 33_306,
78
- 'host' => 'db.example.com'
76
+ "name" => "stratocumulus_test",
77
+ "port" => 33_306,
78
+ "host" => "db.example.com",
79
79
  }
80
80
  end
81
81
 
82
- it 'generates the dump command with the port and host' do
82
+ it "generates the dump command with the port and host" do
83
83
  expect(subject.command).to eq(
84
- 'mysqldump --single-transaction -uroot -hdb.example.com -P33306 stratocumulus_test' # rubocop:disable Style/LineLength
84
+ "mysqldump --single-transaction -uroot -hdb.example.com -P33306 stratocumulus_test" # rubocop:disable Metrics/LineLength
85
85
  )
86
86
  end
87
87
  end
88
88
 
89
- context 'with the username set' do
89
+ context "with the username set" do
90
90
  let(:config) do
91
91
  {
92
- 'name' => 'stratocumulus_test',
93
- 'username' => 'susan'
92
+ "name" => "stratocumulus_test",
93
+ "username" => "susan",
94
94
  }
95
95
  end
96
96
 
97
- it 'generates the dump command with the username' do
97
+ it "generates the dump command with the username" do
98
98
  expect(subject.command).to eq(
99
- 'mysqldump --single-transaction -ususan stratocumulus_test'
99
+ "mysqldump --single-transaction -ususan stratocumulus_test",
100
100
  )
101
101
  end
102
102
  end
@@ -1,21 +1,21 @@
1
1
  # encoding: UTF-8
2
- require 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe Stratocumulus::Database::PipeIO do
5
5
  subject do
6
- described_class.popen('echo foo')
6
+ described_class.popen("echo foo")
7
7
  end
8
8
 
9
9
  after do
10
10
  subject.close
11
11
  end
12
12
 
13
- it 'behaves like IO' do
13
+ it "behaves like IO" do
14
14
  expect(subject.read).to eq "foo\n"
15
15
  end
16
16
 
17
- describe '#rewind' do
18
- it 'is not defined' do
17
+ describe "#rewind" do
18
+ it "is not defined" do
19
19
  expect(subject).to_not respond_to(:rewind)
20
20
  end
21
21
  end
@@ -24,11 +24,11 @@ end
24
24
  describe IO do
25
25
  subject do
26
26
  described_class.open(
27
- described_class.sysopen('spec/support/test_config_file.yml')
27
+ described_class.sysopen("spec/support/test_config_file.yml"),
28
28
  )
29
29
  end
30
30
 
31
- it 'is not affected' do
31
+ it "is not affected" do
32
32
  subject.read
33
33
  subject.rewind
34
34
  expect(subject.read).to_not be_nil
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
- require 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe Stratocumulus::PostgreSQL do
5
5
  subject do
@@ -7,96 +7,96 @@ describe Stratocumulus::PostgreSQL do
7
7
  end
8
8
 
9
9
  let(:config) do
10
- { 'name' => 'stratocumulus_test' }
10
+ { "name" => "stratocumulus_test" }
11
11
  end
12
12
 
13
- describe '#dependencies' do
13
+ describe "#dependencies" do
14
14
  specify do
15
15
  expect(subject.dependencies).to eq %w(gzip pg_dump)
16
16
  end
17
17
  end
18
18
 
19
- describe '#command' do
20
- context 'default' do
21
- it 'generates the dump command with sensible defaults' do
19
+ describe "#command" do
20
+ context "default" do
21
+ it "generates the dump command with sensible defaults" do
22
22
  expect(subject.command).to eq(
23
- 'pg_dump -Upostgres stratocumulus_test'
23
+ "pg_dump -Upostgres stratocumulus_test",
24
24
  )
25
25
  end
26
26
  end
27
27
 
28
- context 'with the password set' do
28
+ context "with the password set" do
29
29
  let(:config) do
30
30
  {
31
- 'name' => 'stratocumulus_test',
32
- 'password' => 'sekret'
31
+ "name" => "stratocumulus_test",
32
+ "password" => "sekret",
33
33
  }
34
34
  end
35
35
 
36
- it 'sets the password env var' do
36
+ it "sets the password env var" do
37
37
  expect(subject.command).to eq(
38
- 'PGPASSWORD="sekret" pg_dump -Upostgres stratocumulus_test'
38
+ 'PGPASSWORD="sekret" pg_dump -Upostgres stratocumulus_test',
39
39
  )
40
40
  end
41
41
  end
42
42
 
43
- context 'with the port set' do
43
+ context "with the port set" do
44
44
  let(:config) do
45
45
  {
46
- 'name' => 'stratocumulus_test',
47
- 'port' => 15_432
46
+ "name" => "stratocumulus_test",
47
+ "port" => 15_432,
48
48
  }
49
49
  end
50
50
 
51
- it 'generates the dump command with a default host' do
51
+ it "generates the dump command with a default host" do
52
52
  expect(subject.command).to eq(
53
- 'pg_dump -Upostgres -hlocalhost -p15432 stratocumulus_test'
53
+ "pg_dump -Upostgres -hlocalhost -p15432 stratocumulus_test",
54
54
  )
55
55
  end
56
56
  end
57
57
 
58
- context 'with the host set' do
58
+ context "with the host set" do
59
59
  let(:config) do
60
60
  {
61
- 'name' => 'stratocumulus_test',
62
- 'host' => 'db.example.com'
61
+ "name" => "stratocumulus_test",
62
+ "host" => "db.example.com",
63
63
  }
64
64
  end
65
65
 
66
- it 'generates the dump command with a default port' do
66
+ it "generates the dump command with a default port" do
67
67
  expect(subject.command).to eq(
68
- 'pg_dump -Upostgres -hdb.example.com -p5432 stratocumulus_test'
68
+ "pg_dump -Upostgres -hdb.example.com -p5432 stratocumulus_test",
69
69
  )
70
70
  end
71
71
  end
72
72
 
73
- context 'with the port and host set' do
73
+ context "with the port and host set" do
74
74
  let(:config) do
75
75
  {
76
- 'name' => 'stratocumulus_test',
77
- 'port' => 15_432,
78
- 'host' => 'db.example.com'
76
+ "name" => "stratocumulus_test",
77
+ "port" => 15_432,
78
+ "host" => "db.example.com",
79
79
  }
80
80
  end
81
81
 
82
- it 'generates the dump command with port and host set' do
82
+ it "generates the dump command with port and host set" do
83
83
  expect(subject.command).to eq(
84
- 'pg_dump -Upostgres -hdb.example.com -p15432 stratocumulus_test'
84
+ "pg_dump -Upostgres -hdb.example.com -p15432 stratocumulus_test",
85
85
  )
86
86
  end
87
87
  end
88
88
 
89
- context 'with the username set' do
89
+ context "with the username set" do
90
90
  let(:config) do
91
91
  {
92
- 'name' => 'stratocumulus_test',
93
- 'username' => 'susan'
92
+ "name" => "stratocumulus_test",
93
+ "username" => "susan",
94
94
  }
95
95
  end
96
96
 
97
- it 'generates the dump command with the username' do
97
+ it "generates the dump command with the username" do
98
98
  expect(subject.command).to eq(
99
- 'pg_dump -Ususan stratocumulus_test'
99
+ "pg_dump -Ususan stratocumulus_test",
100
100
  )
101
101
  end
102
102
  end