dawn-cli 0.9.1 → 0.10.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -3
  3. data/bin/dawni +15 -0
  4. data/lib/dawn/cli/commands.rb +9 -8
  5. data/lib/dawn/cli/commands/app.rb +35 -6
  6. data/lib/dawn/cli/commands/auth.rb +9 -7
  7. data/lib/dawn/cli/commands/base_commands.rb +31 -0
  8. data/lib/dawn/cli/commands/domain.rb +15 -5
  9. data/lib/dawn/cli/commands/drain.rb +15 -5
  10. data/lib/dawn/cli/commands/env.rb +25 -14
  11. data/lib/dawn/cli/commands/key.rb +20 -7
  12. data/lib/dawn/cli/commands/local.rb +13 -3
  13. data/lib/dawn/cli/commands/release.rb +6 -4
  14. data/lib/dawn/cli/helpers.rb +3 -5
  15. data/lib/dawn/cli/output_formatter.rb +15 -2
  16. data/lib/dawn/cli/parser.rb +58 -36
  17. data/lib/dawn/cli/version.rb +2 -2
  18. data/spec/api.log +45272 -0
  19. data/spec/cli/commands/app_spec.rb +71 -0
  20. data/spec/cli/commands/auth_spec.rb +13 -0
  21. data/spec/cli/commands/domain_spec.rb +25 -0
  22. data/spec/cli/commands/drain_spec.rb +25 -0
  23. data/spec/cli/commands/env_spec.rb +26 -0
  24. data/spec/cli/commands/key_spec.rb +30 -0
  25. data/spec/cli/commands/local_spec.rb +15 -0
  26. data/spec/cli/commands/release_spec.rb +19 -0
  27. data/spec/cli/parser_spec.rb +262 -0
  28. data/spec/cli_spec_helper.rb +13 -0
  29. data/spec/support/vcr.rb +11 -0
  30. data/spec/vcr/Dawn_CLI_App/_create/should_create_a_new_app_with_a_name.yml +51 -0
  31. data/spec/vcr/Dawn_CLI_App/_create/should_create_a_new_app_without_a_name.yml +51 -0
  32. data/spec/vcr/Dawn_CLI_App/_delete/should_delete_current_app.yml +98 -0
  33. data/spec/vcr/Dawn_CLI_App/_list/should_list_all_available_apps.yml +65 -0
  34. data/spec/vcr/Dawn_CLI_App/_list_gears/should_list_all_gears_for_current_app.yml +98 -0
  35. data/spec/vcr/Dawn_CLI_App/_logs/should_trail_the_current_app_s_logs.yml +98 -0
  36. data/spec/vcr/Dawn_CLI_App/_scale/should_modify_the_formation_for_the_current_app.yml +98 -0
  37. data/spec/vcr/Dawn_CLI_Auth/_login/should_login_using_proper_credentials.yml +48 -0
  38. data/spec/vcr/Dawn_CLI_Auth/_login/should_not_login_using_invalid_credentials.yml +46 -0
  39. data/spec/vcr/Dawn_CLI_Domain/_add/should_add_a_domain_to_the_current_app.yml +96 -0
  40. data/spec/vcr/Dawn_CLI_Domain/_delete/should_delete_a_domain_to_the_current_app.yml +97 -0
  41. data/spec/vcr/Dawn_CLI_Domain/_list/should_list_all_domains_for_current_app.yml +102 -0
  42. data/spec/vcr/Dawn_CLI_Drain/_add/should_add_a_drain_to_the_current_app.yml +359 -0
  43. data/spec/vcr/Dawn_CLI_Drain/_delete/should_remove_a_drain_from_current_app.yml +476 -0
  44. data/spec/vcr/Dawn_CLI_Drain/_list/should_list_all_drains_for_current_app.yml +98 -0
  45. data/spec/vcr/Dawn_CLI_Env/_get/should_retrieve_an_ENV_variable_given_a_key.yml +51 -0
  46. data/spec/vcr/Dawn_CLI_Env/_set/should_set_an_ENV_variable_given_a_Hash.yml +424 -0
  47. data/spec/vcr/Dawn_CLI_Env/_unset/should_remove_an_ENV_variable_given_a_key.yml +275 -0
  48. data/spec/vcr/Dawn_CLI_Key/_add/should_add_existing_id_rsa.yml +52 -0
  49. data/spec/vcr/Dawn_CLI_Key/_delete/should_delete_a_key_by_id.yml +101 -0
  50. data/spec/vcr/Dawn_CLI_Key/_get/should_retrieve_a_key_by_id.yml +102 -0
  51. data/spec/vcr/Dawn_CLI_Key/_list/should_list_all_keys_deployed.yml +53 -0
  52. data/spec/vcr/Dawn_CLI_Local/_health_check/should_verify_that_server_is_running.yml +50 -0
  53. data/spec/vcr/Dawn_CLI_Local/_whoami/should_print_current_user_to_console.yml +51 -0
  54. metadata +43 -4
@@ -0,0 +1,71 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::App, :vcr do
4
+ before :all do
5
+ Dawn::CLI.selected_app = "app-test"
6
+ end
7
+
8
+ context ".create" do
9
+ it "should create a new app without a name" do
10
+ Dawn::CLI::App.create nil
11
+ end
12
+
13
+ it "should create a new app with a name" do
14
+ Dawn::CLI::App.create "crispy-judge"
15
+ end
16
+ end
17
+
18
+ context ".list" do
19
+ it "should list all available apps" do
20
+ Dawn::CLI::App.list
21
+ end
22
+ end
23
+
24
+ context ".list_gears" do
25
+ it "should list all gears for current app" do
26
+ Dawn::CLI::App.list_gears
27
+ end
28
+ end
29
+
30
+ context ".scale" do
31
+ it "should modify the formation for the current app" do
32
+ Dawn::CLI::App.scale("web" => ["+", 1])
33
+ end
34
+ end
35
+
36
+ context ".run" do
37
+ it "should run a command on current app" do
38
+ Dawn::CLI::App.run(%w[bash --version])
39
+ end
40
+
41
+ it "should fail if no command is given" do
42
+ Dawn::CLI::App.run(%w[])
43
+ end
44
+ end
45
+
46
+ context ".logs" do
47
+ it "should trail the current app's logs" do
48
+ Dawn::CLI::App.logs([], false)
49
+ end
50
+ end
51
+
52
+ context ".restart" do
53
+ it "should restart current app" do
54
+ Dawn::CLI::App.restart
55
+ end
56
+ end
57
+
58
+ context ".delete" do
59
+ before :all do
60
+ Dawn::CLI.selected_app = "crispy-judge"
61
+ end
62
+
63
+ after :all do
64
+ Dawn::CLI.selected_app = "app-test"
65
+ end
66
+
67
+ it "should delete current app" do
68
+ Dawn::CLI::App.delete
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,13 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Auth, :vcr do
4
+ context ".login" do
5
+ it "should not login using invalid credentials" do
6
+ expect { Dawn::CLI::Auth.login("SomeGuy", "withsomepassword") }.to raise_error(SystemExit)
7
+ end
8
+
9
+ it "should login using proper credentials" do
10
+ Dawn::CLI::Auth.login("IceDragon", "creampuff")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Domain, :vcr do
4
+ before :all do
5
+ Dawn::CLI.selected_app = "domain-test"
6
+ end
7
+
8
+ context ".list" do
9
+ it "should list all domains for current app" do
10
+ Dawn::CLI::Domain.list
11
+ end
12
+ end
13
+
14
+ context ".add" do
15
+ it "should add a domain to the current app" do
16
+ Dawn::CLI::Domain.add("itwasadomain.io")
17
+ end
18
+ end
19
+
20
+ context ".delete" do
21
+ it "should delete a domain to the current app" do
22
+ Dawn::CLI::Domain.delete("cc-rushers.io")
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Drain, :vcr do
4
+ before :all do
5
+ Dawn::CLI.selected_app = "drain-test"
6
+ end
7
+
8
+ context ".list" do
9
+ it "should list all drains for current app" do
10
+ Dawn::CLI::Drain.list
11
+ end
12
+ end
13
+
14
+ context ".add" do
15
+ it "should add a drain to the current app" do
16
+ Dawn::CLI::Drain.add("flushing.io")
17
+ end
18
+ end
19
+
20
+ context ".delete" do
21
+ it "should remove a drain from current app" do
22
+ Dawn::CLI::Drain.delete("flushing.io")
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Env, :vcr do
4
+ before :all do
5
+ Dawn::CLI.selected_app = "env-test"
6
+ end
7
+
8
+ context ".get" do
9
+ it "should retrieve an ENV variable given a key" do
10
+ Dawn::CLI::Env.get("HOSTNAME")
11
+ end
12
+ end
13
+
14
+ context ".set" do
15
+ it "should set an ENV variable given a Hash" do
16
+ Dawn::CLI::Env.set("LemmeAtIt" => "maybe")
17
+ end
18
+ end
19
+
20
+ context ".unset" do
21
+ it "should remove an ENV variable given a key" do
22
+ Dawn::CLI::Env.unset("LemmeAtIt")
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,30 @@
1
+ require 'cli_spec_helper'
2
+ require "sshkey"
3
+
4
+ describe Dawn::CLI::Key, :vcr do
5
+ context ".list" do
6
+ it "should list all keys deployed" do
7
+ Dawn::CLI::Key.list
8
+ end
9
+ end
10
+
11
+ context ".add" do
12
+ it "should add existing id_rsa" do
13
+ Dawn::CLI::Key.add
14
+ end
15
+ end
16
+
17
+ context ".get" do
18
+ it "should retrieve a key by id" do
19
+ key = Dawn::Key.all.last
20
+ Dawn::CLI::Key.get(key.id)
21
+ end
22
+ end
23
+
24
+ context ".delete" do
25
+ it "should delete a key by id" do
26
+ key = Dawn::Key.all.last
27
+ Dawn::CLI::Key.delete(key.id)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Local, :vcr do
4
+ context ".health_check" do
5
+ it "should verify that server is running" do
6
+ Dawn::CLI::Local.health_check
7
+ end
8
+ end
9
+
10
+ context ".whoami" do
11
+ it "should print current user to console" do
12
+ Dawn::CLI::Local.whoami
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI::Release, :vcr do
4
+ before :all do
5
+ Dawn::CLI.selected_app = "release-test"
6
+ end
7
+
8
+ context ".list" do
9
+ it "should list all releases for the current app" do
10
+ Dawn::CLI::Release.list
11
+ end
12
+ end
13
+
14
+ context ".add" do
15
+ it "should add a new release to the current app" do
16
+ Dawn::CLI::Release.add
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,262 @@
1
+ require 'cli_spec_helper'
2
+
3
+ describe Dawn::CLI do
4
+ before :all do
5
+ Dawn::CLI.no_operation = true
6
+ end
7
+
8
+ after :all do
9
+ Dawn::CLI.no_operation = false
10
+ end
11
+
12
+ describe ".run" do
13
+ context "when a given command does not exist" do
14
+ it "should abort execution" do
15
+ expect { Dawn::CLI.run(%w[hamburger]) }.to raise_error(SystemExit)
16
+ end
17
+ end
18
+
19
+ context "when given a `create` command" do
20
+ it "should accept command without parameters" do
21
+ expect(Dawn::CLI.run(%w[create])).to eq(:create)
22
+ end
23
+
24
+ it "should accept command with 1 parameter" do
25
+ expect(Dawn::CLI.run(%w[create cheese-crunch])).to eq(:create)
26
+ end
27
+ end
28
+
29
+ context "when given a `ls` command" do
30
+ it "should accept command without parameters" do
31
+ expect(Dawn::CLI.run(%w[ls])).to eq(:list)
32
+ end
33
+ end
34
+
35
+ context "when given a `ps` command" do
36
+ it "should accept command without parameters" do
37
+ expect(Dawn::CLI.run(%w[ps])).to eq(:list_gears)
38
+ end
39
+ end
40
+
41
+ ## login will not be tested since it requires user interaction
42
+
43
+ context "when given a `logs` command" do
44
+ it "should accept command without parameters" do
45
+ expect(Dawn::CLI.run(%w[logs])).to eq(:logs)
46
+ end
47
+ end
48
+
49
+ context "when given an `app` command" do
50
+ it "should accept command without parameters" do
51
+ Dawn::CLI.run(%w[app])
52
+ end
53
+
54
+ it "should default to list" do
55
+ expect(Dawn::CLI.run(%w[app])).to eq(:list)
56
+ end
57
+
58
+ context "delete" do
59
+ it "should accept without parameters" do
60
+ expect(Dawn::CLI.run(%w[app delete])).to eq(:delete)
61
+ end
62
+ end
63
+
64
+ context "restart" do
65
+ it "should accept without parameters" do
66
+ expect(Dawn::CLI.run(%w[app restart])).to eq(:restart)
67
+ end
68
+ end
69
+
70
+ context "scale" do
71
+ it "should not accept without parameters" do
72
+ expect { Dawn::CLI.run(%w[app scale]) }.to raise_error(SystemExit)
73
+ end
74
+
75
+ it "should accept with parameters" do
76
+ expect(Dawn::CLI.run(%w[app scale web+1])).to eq(:scale)
77
+ end
78
+ end
79
+ end
80
+
81
+ context "when given a `domain` command" do
82
+ it "should accept command without parameters" do
83
+ Dawn::CLI.run(%w[domain])
84
+ end
85
+
86
+ it "should default to list" do
87
+ expect(Dawn::CLI.run(%w[domain])).to eq(:list)
88
+ end
89
+
90
+ context "add" do
91
+ it "should not accept without parameters" do
92
+ expect { Dawn::CLI.run(%w[domain add]) }.to raise_error(SystemExit)
93
+ end
94
+
95
+ it "should accept with parameters" do
96
+ expect(Dawn::CLI.run(%w[domain add http://alliswell.io])).to eq(:add)
97
+ end
98
+ end
99
+
100
+ context "delete" do
101
+ it "should not accept without parameters" do
102
+ expect { Dawn::CLI.run(%w[domain delete]) }.to raise_error(SystemExit)
103
+ end
104
+
105
+ it "should accept with parameters" do
106
+ expect(Dawn::CLI.run(%w[domain delete http://alliswell.io])).to eq(:delete)
107
+ end
108
+ end
109
+ end
110
+
111
+ context "when given a `drain` command" do
112
+ it "should accept command without parameters" do
113
+ Dawn::CLI.run(%w[drain])
114
+ end
115
+
116
+ it "should default to list" do
117
+ expect(Dawn::CLI.run(%w[drain])).to eq(:list)
118
+ end
119
+
120
+ context "add" do
121
+ it "should not accept without parameters" do
122
+ expect { Dawn::CLI.run(%w[drain add]) }.to raise_error(SystemExit)
123
+ end
124
+
125
+ it "should accept with parameters" do
126
+ expect(Dawn::CLI.run(%w[drain add http://alliswell.io])).to eq(:add)
127
+ end
128
+ end
129
+
130
+ context "delete" do
131
+ it "should not accept without parameters" do
132
+ expect { Dawn::CLI.run(%w[drain delete]) }.to raise_error(SystemExit)
133
+ end
134
+
135
+ it "should accept with parameters" do
136
+ expect(Dawn::CLI.run(%w[drain delete http://alliswell.io])).to eq(:delete)
137
+ end
138
+ end
139
+ end
140
+
141
+ context "when given an `env` command" do
142
+ it "should accept command without parameters" do
143
+ Dawn::CLI.run(%w[env])
144
+ end
145
+
146
+ it "should default to list" do
147
+ expect(Dawn::CLI.run(%w[env])).to eq(:list)
148
+ end
149
+
150
+ context "get" do
151
+ it "should not accept without parameters" do
152
+ expect { Dawn::CLI.run(%w[env get]) }.to raise_error(SystemExit)
153
+ end
154
+
155
+ it "should accept with parameter" do
156
+ expect(Dawn::CLI.run(%w[env get HOSTNAME])).to eq(:get)
157
+ end
158
+
159
+ it "should accept with multiple parameters" do
160
+ expect(Dawn::CLI.run(%w[env get HOSTNAME BREAD EGGS AND CHEESE])).to eq(:get)
161
+ end
162
+ end
163
+
164
+ context "set" do
165
+ it "should not accept without parameters" do
166
+ expect { Dawn::CLI.run(%w[env set]) }.to raise_error(SystemExit)
167
+ end
168
+
169
+ it "should accept with parameter" do
170
+ expect(Dawn::CLI.run(%w[env set HOSTNAME=kana])).to eq(:set)
171
+ end
172
+
173
+ it "should accept with multiple parameters" do
174
+ expect(Dawn::CLI.run(%W[env set HOSTNAME=kana BREAD=wheat EGGS=3 AND="YEAH" CHEESE="the\sblue\skind"])).to eq(:set)
175
+ end
176
+ end
177
+
178
+ context "unset" do
179
+ it "should not accept without parameters" do
180
+ expect { Dawn::CLI.run(%w[env unset]) }.to raise_error(SystemExit)
181
+ end
182
+
183
+ it "should accept with parameter" do
184
+ expect(Dawn::CLI.run(%w[env unset HOSTNAME])).to eq(:unset)
185
+ end
186
+
187
+ it "should accept with multiple parameters" do
188
+ expect(Dawn::CLI.run(%w[env unset HOSTNAME BREAD EGGS AND CHEESE])).to eq(:unset)
189
+ end
190
+ end
191
+ end
192
+
193
+ context "when given a `key` command" do
194
+ it "should accept command without parameters" do
195
+ Dawn::CLI.run(%w[key])
196
+ end
197
+
198
+ it "should default to list" do
199
+ expect(Dawn::CLI.run(%w[key])).to eq(:list)
200
+ end
201
+
202
+ context "add" do
203
+ it "should accept without parameters" do
204
+ expect(Dawn::CLI.run(%w[key add])).to eq(:add)
205
+ end
206
+ end
207
+
208
+ context "delete" do
209
+ it "should not accept without parameters" do
210
+ expect { Dawn::CLI.run(%w[key delete]) }.to raise_error(SystemExit)
211
+ end
212
+
213
+ it "should accept with parameters" do
214
+ expect(Dawn::CLI.run(%w[key delete 14])).to eq(:delete)
215
+ end
216
+ end
217
+
218
+ context "get" do
219
+ it "should not accept without parameters" do
220
+ expect { Dawn::CLI.run(%w[key get]) }.to raise_error(SystemExit)
221
+ end
222
+
223
+ it "should accept with parameters" do
224
+ expect(Dawn::CLI.run(%w[key get 13])).to eq(:get)
225
+ end
226
+ end
227
+ end
228
+
229
+ context "when given a `release` command" do
230
+ it "should accept command without parameters" do
231
+ Dawn::CLI.run(%w[release])
232
+ end
233
+
234
+ it "should default to list" do
235
+ expect(Dawn::CLI.run(%w[release])).to eq(:list)
236
+ end
237
+
238
+ context "add" do
239
+ it "should accept without parameters" do
240
+ expect(Dawn::CLI.run(%w[release add])).to eq(:add)
241
+ end
242
+ end
243
+ end
244
+
245
+ ## not sure how to test run
246
+ context "when given a `run` command" do
247
+ it "should accept command without parameters" do
248
+ Dawn::CLI.run(%w[run])
249
+ end
250
+
251
+ it "should default to list" do
252
+ expect(Dawn::CLI.run(%w[run])).to eq(:run)
253
+ end
254
+ end
255
+
256
+ context "when given a `health-check` command" do
257
+ it "should accept command without parameters" do
258
+ expect(Dawn::CLI.run(%w[health-check])).to eq(:health_check)
259
+ end
260
+ end
261
+ end
262
+ end