azuki-api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +4 -0
  5. data/README.md +128 -0
  6. data/Rakefile +41 -0
  7. data/azuki-api.gemspec +23 -0
  8. data/changelog.txt +204 -0
  9. data/lib/azuki-api.rb +1 -0
  10. data/lib/azuki/api.rb +146 -0
  11. data/lib/azuki/api/addons.rb +48 -0
  12. data/lib/azuki/api/apps.rb +71 -0
  13. data/lib/azuki/api/attachments.rb +14 -0
  14. data/lib/azuki/api/collaborators.rb +33 -0
  15. data/lib/azuki/api/config_vars.rb +33 -0
  16. data/lib/azuki/api/domains.rb +42 -0
  17. data/lib/azuki/api/errors.rb +26 -0
  18. data/lib/azuki/api/features.rb +45 -0
  19. data/lib/azuki/api/keys.rb +42 -0
  20. data/lib/azuki/api/login.rb +14 -0
  21. data/lib/azuki/api/logs.rb +18 -0
  22. data/lib/azuki/api/mock.rb +179 -0
  23. data/lib/azuki/api/mock/addons.rb +153 -0
  24. data/lib/azuki/api/mock/apps.rb +205 -0
  25. data/lib/azuki/api/mock/attachments.rb +19 -0
  26. data/lib/azuki/api/mock/cache/get_addons.json +1 -0
  27. data/lib/azuki/api/mock/cache/get_features.json +1 -0
  28. data/lib/azuki/api/mock/cache/get_user.json +1 -0
  29. data/lib/azuki/api/mock/collaborators.rb +55 -0
  30. data/lib/azuki/api/mock/config_vars.rb +49 -0
  31. data/lib/azuki/api/mock/domains.rb +80 -0
  32. data/lib/azuki/api/mock/features.rb +120 -0
  33. data/lib/azuki/api/mock/keys.rb +46 -0
  34. data/lib/azuki/api/mock/login.rb +22 -0
  35. data/lib/azuki/api/mock/logs.rb +20 -0
  36. data/lib/azuki/api/mock/processes.rb +198 -0
  37. data/lib/azuki/api/mock/releases.rb +69 -0
  38. data/lib/azuki/api/mock/stacks.rb +83 -0
  39. data/lib/azuki/api/mock/user.rb +16 -0
  40. data/lib/azuki/api/processes.rb +77 -0
  41. data/lib/azuki/api/releases.rb +33 -0
  42. data/lib/azuki/api/ssl_endpoints.rb +62 -0
  43. data/lib/azuki/api/stacks.rb +22 -0
  44. data/lib/azuki/api/user.rb +14 -0
  45. data/lib/azuki/api/vendor/okjson.rb +600 -0
  46. data/lib/azuki/api/version.rb +5 -0
  47. data/test/data/site.crt +19 -0
  48. data/test/data/site.key +27 -0
  49. data/test/test_addons.rb +193 -0
  50. data/test/test_apps.rb +147 -0
  51. data/test/test_attachments.rb +23 -0
  52. data/test/test_collaborators.rb +73 -0
  53. data/test/test_config_vars.rb +54 -0
  54. data/test/test_domains.rb +65 -0
  55. data/test/test_error_conditions.rb +11 -0
  56. data/test/test_features.rb +87 -0
  57. data/test/test_helper.rb +48 -0
  58. data/test/test_keys.rb +39 -0
  59. data/test/test_login.rb +20 -0
  60. data/test/test_logs.rb +29 -0
  61. data/test/test_processes.rb +245 -0
  62. data/test/test_releases.rb +73 -0
  63. data/test/test_ssl_endpoints.rb +132 -0
  64. data/test/test_stacks.rb +49 -0
  65. data/test/test_user.rb +13 -0
  66. metadata +168 -0
@@ -0,0 +1,54 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestConfigVars < MiniTest::Unit::TestCase
4
+
5
+ def test_delete_app_config_var
6
+ with_app('stack' => 'cedar') do |app_data|
7
+ azuki.put_config_vars(app_data['name'], {'KEY' => 'value'})
8
+
9
+ response = azuki.delete_config_var(app_data['name'], 'KEY')
10
+
11
+ assert_equal(200, response.status)
12
+ assert_equal({}, response.body)
13
+ end
14
+ end
15
+
16
+ def test_delete_app_config_var_app_not_found
17
+ assert_raises(Azuki::API::Errors::NotFound) do
18
+ azuki.delete_config_var(random_name, 'key')
19
+ end
20
+ end
21
+
22
+ def test_get_app_config_vars
23
+ with_app('stack' => 'cedar') do |app_data|
24
+ response = azuki.get_config_vars(app_data['name'])
25
+
26
+ assert_equal(200, response.status)
27
+ assert_equal({}, response.body)
28
+ end
29
+ end
30
+
31
+ def test_get_app_config_vars_app_not_found
32
+ assert_raises(Azuki::API::Errors::NotFound) do
33
+ azuki.get_config_vars(random_name)
34
+ end
35
+ end
36
+
37
+ def test_put_app_config_vars
38
+ with_app('stack' => 'cedar') do |app_data|
39
+ response = azuki.put_config_vars(app_data['name'], {'KEY' => 'value'})
40
+
41
+ assert_equal(200, response.status)
42
+ assert_equal({'KEY' => 'value'}, response.body)
43
+
44
+ azuki.delete_config_var(app_data['name'], 'KEY')
45
+ end
46
+ end
47
+
48
+ def test_put_app_config_vars_app_not_found
49
+ assert_raises(Azuki::API::Errors::NotFound) do
50
+ azuki.put_config_vars(random_name, {'KEY' => 'value'})
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,65 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestDomains < MiniTest::Unit::TestCase
4
+
5
+ def test_delete_domain_app_not_found
6
+ assert_raises(Azuki::API::Errors::NotFound) do
7
+ azuki.delete_domain(random_name, 'example.com')
8
+ end
9
+ end
10
+
11
+ def test_delete_domain
12
+ with_app do |app_data|
13
+ domain = random_domain
14
+ azuki.post_domain(app_data['name'], domain)
15
+ response = azuki.delete_domain(app_data['name'], domain)
16
+
17
+ assert_equal(200, response.status)
18
+ assert_equal({}, response.body)
19
+ end
20
+ end
21
+
22
+ def test_delete_domains
23
+ with_app do |app_data|
24
+ azuki.post_domain(app_data['name'], random_domain)
25
+ response = azuki.delete_domains(app_data['name'])
26
+
27
+ assert_equal(200, response.status)
28
+ assert_equal("", response.body)
29
+ end
30
+ end
31
+
32
+ def test_get_domains
33
+ with_app do |app_data|
34
+ response = azuki.get_domains(app_data['name'])
35
+
36
+ assert_equal(200, response.status)
37
+ assert_equal([], response.body)
38
+ end
39
+ end
40
+
41
+ def test_get_domains_app_not_found
42
+ assert_raises(Azuki::API::Errors::NotFound) do
43
+ azuki.get_domains(random_name)
44
+ end
45
+ end
46
+
47
+ def test_post_domain
48
+ with_app do |app_data|
49
+ domain = random_domain
50
+ response = azuki.post_domain(app_data['name'], domain)
51
+
52
+ assert_equal(201, response.status)
53
+ assert_equal({'domain' => domain}, response.body)
54
+
55
+ azuki.delete_domain(app_data['name'], domain)
56
+ end
57
+ end
58
+
59
+ def test_post_domain_app_not_found
60
+ assert_raises(Azuki::API::Errors::NotFound) do
61
+ azuki.post_domain(random_name, 'example.com')
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestErrorConditions < MiniTest::Unit::TestCase
4
+
5
+ def test_request_without_app_returns_a_sensible_error
6
+ assert_raises(Azuki::API::Errors::NilApp) do
7
+ azuki.delete_domain("", 'example.com')
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,87 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestFeatures < MiniTest::Unit::TestCase
4
+
5
+ def setup
6
+ @feature_data ||= begin
7
+ data = File.read("#{File.dirname(__FILE__)}/../lib/azuki/api/mock/cache/get_features.json")
8
+ features_data = Azuki::API::OkJson.decode(data)
9
+ features_data.detect {|feature| feature['name'] == 'user_env_compile'}
10
+ end
11
+ end
12
+
13
+ def test_delete_feature
14
+ with_app do |app_data|
15
+ azuki.post_feature('user_env_compile', app_data['name'])
16
+ response = azuki.delete_feature('user_env_compile', app_data['name'])
17
+
18
+ assert_equal(200, response.status)
19
+ assert_equal(@feature_data, response.body)
20
+ end
21
+ end
22
+
23
+ def test_delete_feature_app_not_found
24
+ assert_raises(Azuki::API::Errors::RequestFailed) do
25
+ azuki.delete_feature('user_env_compile', random_name)
26
+ end
27
+ end
28
+
29
+ def test_delete_feature_feature_not_found
30
+ with_app do |app_data|
31
+ assert_raises(Azuki::API::Errors::NotFound) do
32
+ azuki.delete_feature(random_name, app_data['name'])
33
+ end
34
+ end
35
+ end
36
+
37
+ def test_get_features
38
+ with_app do |app_data|
39
+ response = azuki.get_features(app_data['name'])
40
+ data = File.read("#{File.dirname(__FILE__)}/../lib/azuki/api/mock/cache/get_features.json")
41
+
42
+ assert_equal(200, response.status)
43
+ assert_equal(Azuki::API::OkJson.decode(data), response.body)
44
+ end
45
+ end
46
+
47
+ def test_get_feature
48
+ with_app do |app_data|
49
+ response = azuki.get_feature('user_env_compile', app_data['name'])
50
+
51
+ assert_equal(200, response.status)
52
+ assert_equal(@feature_data, response.body)
53
+ end
54
+ end
55
+
56
+ def test_get_features_feature_not_found
57
+ with_app do |app_data|
58
+ assert_raises(Azuki::API::Errors::NotFound) do
59
+ azuki.get_feature(random_name, app_data['name'])
60
+ end
61
+ end
62
+ end
63
+
64
+ def test_post_feature
65
+ with_app do |app_data|
66
+ response = azuki.post_feature('user_env_compile', app_data['name'])
67
+
68
+ assert_equal(201, response.status)
69
+ assert_equal(@feature_data.merge('enabled' => true), response.body)
70
+ end
71
+ end
72
+
73
+ def test_post_feature_app_not_found
74
+ assert_raises(Azuki::API::Errors::NotFound) do
75
+ azuki.post_feature('user_env_compile', random_name)
76
+ end
77
+ end
78
+
79
+ def test_post_feature_feature_not_found
80
+ with_app do |app_data|
81
+ assert_raises(Azuki::API::Errors::NotFound) do
82
+ azuki.post_feature(random_name, app_data['name'])
83
+ end
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../lib/azuki/api")
2
+
3
+ require 'rubygems'
4
+ gem 'minitest' # ensure we are using the gem version
5
+ require 'minitest/autorun'
6
+ require 'time'
7
+
8
+ DATA_PATH = File.expand_path("#{File.dirname(__FILE__)}/data")
9
+ MOCK = ENV['MOCK'] != 'false'
10
+
11
+ def data_site_crt
12
+ @data_site_crt ||= File.read(File.join(DATA_PATH, 'site.crt'))
13
+ end
14
+
15
+ def data_site_key
16
+ @data_site_key ||= File.read(File.join(DATA_PATH, 'site.key'))
17
+ end
18
+
19
+ def azuki
20
+ # ENV['AZUKI_API_KEY'] used for :api_key
21
+ Azuki::API.new(:mock => MOCK)
22
+ end
23
+
24
+ def random_domain
25
+ "#{random_name}.com"
26
+ end
27
+
28
+ def random_name
29
+ "azuki-rb-#{SecureRandom.hex(10)}"
30
+ end
31
+
32
+ def random_email_address
33
+ "email@#{random_name}.com"
34
+ end
35
+
36
+ def with_app(params={}, &block)
37
+ begin
38
+ data = azuki.post_app(params).body
39
+ @name = data['name']
40
+ ready = false
41
+ until ready
42
+ ready = azuki.request(:method => :put, :path => "/apps/#{@name}/status").status == 201
43
+ end
44
+ yield(data)
45
+ ensure
46
+ azuki.delete_app(@name) rescue nil
47
+ end
48
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestKeys < MiniTest::Unit::TestCase
4
+ KEY_DATA = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCz29znMi/UJX/nvkRSO5FFugKhU9DkkI53E0vXUnP8zeLFxMgyUqmXryPVjWtGzz2LRWqjm14SbqHAmM44pGHVfBIp6wCKBWSUYGv/FxOulwYgtWzz4moxWLZrFyWWgJAnehcVUifHNgzKwT2ovWm2ns52681Z8yFK3K8/uLStDjLIaPePEOaxaTvgIxZNsfyEoXoHcyTPwdR1GtQuDTuDYqYmjmPCoKybYnXrTQ1QFuQxDneBkswQYSl0H2aLf3uBK4F01hr+azXQuSe39eSV4I/TqzmNJlanpILT9Jz3/J1i4r6brpF3AxLnFnb9ufIbzQAIa/VZIulfrZkcBsUl david@carbon.local"
5
+
6
+ def test_delete_key_key_not_found
7
+ assert_raises(Azuki::API::Errors::NotFound) do
8
+ azuki.delete_key(random_name)
9
+ end
10
+ end
11
+
12
+ def test_delete_key
13
+ azuki.post_key(KEY_DATA)
14
+ response = azuki.delete_key('david@carbon.local')
15
+
16
+ assert_equal(200, response.status)
17
+ end
18
+
19
+ def test_delete_keys
20
+ response = azuki.delete_keys
21
+
22
+ assert_equal(200, response.status)
23
+ end
24
+
25
+ def test_get_keys
26
+ response = azuki.get_keys
27
+
28
+ assert_equal(200, response.status)
29
+ end
30
+
31
+ def test_post_key
32
+ response = azuki.post_key(KEY_DATA)
33
+
34
+ assert_equal(200, response.status)
35
+
36
+ azuki.delete_key('david@carbon.local')
37
+ end
38
+
39
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestLogin < MiniTest::Unit::TestCase
4
+
5
+ def test_post_login
6
+ # FIXME: user/pass will only work in mock for now, maybe use ENV
7
+ response = azuki.post_login('email@example.com', 'fake_password')
8
+
9
+ assert_equal(200, response.status)
10
+ end
11
+
12
+ def test_post_login_implied
13
+ # FIXME: user/pass will only work in mock for now, maybe use ENV
14
+ _azuki_ = Azuki::API.new(:mock => true, :username => 'email@example.com', :password => 'fake_password')
15
+ response = _azuki_.get_apps
16
+
17
+ assert_equal(200, response.status)
18
+ end
19
+
20
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestLogs < MiniTest::Unit::TestCase
4
+
5
+ def test_get_logs
6
+ with_app do |app_data|
7
+ response = azuki.get_logs(app_data['name'], 'logplex' => true)
8
+
9
+ assert_equal(200, response.status)
10
+ assert_match(%r{^https://logplex\.azukiapp\.com/sessions/[-a-zA-Z0-9]*\?srv=[0-9]*$}, response.body)
11
+ end
12
+ end
13
+
14
+ def test_get_logs_no_options
15
+ with_app do |app_data|
16
+ response = azuki.get_logs(app_data['name'])
17
+
18
+ assert_equal(200, response.status)
19
+ assert_match(%r{^https://logplex\.azukiapp\.com/sessions/[-a-zA-Z0-9]*\?srv=[0-9]*$}, response.body)
20
+ end
21
+ end
22
+
23
+ def test_get_logs_app_not_found
24
+ assert_raises(Azuki::API::Errors::NotFound) do
25
+ azuki.get_logs(random_name, 'logplex' => true)
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,245 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestProcesses < MiniTest::Unit::TestCase
4
+
5
+ def test_get_ps
6
+ with_app do |app_data|
7
+ response = azuki.get_ps(app_data['name'])
8
+ ps = response.body.first
9
+
10
+ assert_equal(200, response.status)
11
+ assert_equal('up', ps['action'])
12
+ assert_equal(app_data['name'], ps['app_name'])
13
+ assert_equal(false, ps['attached'])
14
+ assert_equal('thin -p $PORT -e $RACK_ENV -R $AZUKI_RACK start', ps['command'])
15
+ # elapsed
16
+ # pretty_state
17
+ assert_equal('web.1', ps['process'])
18
+ assert_equal(nil, ps['rendevous_url'])
19
+ assert_equal('NONE', ps['slug'])
20
+ assert_equal('created', ps['state'])
21
+ # transitioned_at
22
+ assert_equal('Dyno', ps['type'])
23
+ # upid
24
+ end
25
+ end
26
+
27
+ def test_get_ps_app_not_found
28
+ assert_raises(Azuki::API::Errors::NotFound) do
29
+ azuki.get_ps(random_name)
30
+ end
31
+ end
32
+
33
+ def test_post_ps
34
+ with_app do |app_data|
35
+ command = 'pwd'
36
+ response = azuki.post_ps(app_data['name'], command)
37
+ ps = response.body
38
+
39
+ assert_equal(200, response.status)
40
+ assert_equal('complete', ps['action'])
41
+ refute(ps['attached'])
42
+ assert_equal(command, ps['command'])
43
+ # elapsed
44
+ # pretty_state
45
+ assert_equal('run.1', ps['process'])
46
+ assert_nil(ps['rendevous_url'])
47
+ assert_equal('NONE', ps['slug'])
48
+ # depending on timing it will be one of these two states
49
+ assert_includes(['created', 'starting'], ps['state'])
50
+ # transitioned_at
51
+ assert_equal('Ps', ps['type'])
52
+ # upid
53
+ end
54
+ end
55
+
56
+ def test_post_ps_with_attach
57
+ with_app do |app_data|
58
+ command = 'pwd'
59
+ response = azuki.post_ps(app_data['name'], command, 'attach' => true)
60
+ ps = response.body
61
+
62
+ assert_equal(200, response.status)
63
+ assert_equal('complete', ps['action'])
64
+ assert(ps['attached'])
65
+ assert_equal(command, ps['command'])
66
+ # elapsed
67
+ # pretty_state
68
+ assert_equal('run.1', ps['process'])
69
+ refute_nil(ps['rendezvous_url'])
70
+ assert_equal('NONE', ps['slug'])
71
+ # depending on timing it will be one of these two states
72
+ assert_includes(['created', 'starting'], ps['state'])
73
+ # transitioned_at
74
+ assert_equal(nil, ps['type'])
75
+ # upid
76
+ end
77
+ end
78
+
79
+ def test_post_ps_app_not_found
80
+ assert_raises(Azuki::API::Errors::NotFound) do
81
+ azuki.post_ps(random_name, 'pwd')
82
+ end
83
+ end
84
+
85
+ def test_post_ps_restart
86
+ with_app do |app_data|
87
+ response = azuki.post_ps_restart(app_data['name'])
88
+
89
+ assert_equal(200, response.status)
90
+ assert_equal('ok', response.body)
91
+ end
92
+ end
93
+
94
+ def test_post_ps_restart_with_ps
95
+ with_app do |app_data|
96
+ response = azuki.post_ps_restart(app_data['name'], 'ps' => 'web.1')
97
+
98
+ assert_equal(200, response.status)
99
+ assert_equal('ok', response.body)
100
+ end
101
+ end
102
+
103
+ def test_post_ps_restart_with_type
104
+ with_app do |app_data|
105
+ response = azuki.post_ps_restart(app_data['name'], 'type' => 'web')
106
+
107
+ assert_equal(200, response.status)
108
+ assert_equal('ok', response.body)
109
+ end
110
+ end
111
+
112
+ def test_post_ps_restart_app_not_found
113
+ assert_raises(Azuki::API::Errors::NotFound) do
114
+ azuki.post_ps_restart(random_name)
115
+ end
116
+ end
117
+
118
+ def test_post_ps_scale_app_not_found
119
+ assert_raises(Azuki::API::Errors::NotFound) do
120
+ azuki.post_ps_scale(random_name, 'web', 2)
121
+ end
122
+ end
123
+
124
+ def test_post_ps_scale_down
125
+ with_app('stack' => 'cedar') do |app_data|
126
+ azuki.post_ps_scale(app_data['name'], 'web', 2)
127
+ response = azuki.post_ps_scale(app_data['name'], 'web', 1)
128
+
129
+ assert_equal(200, response.status)
130
+ assert_equal("1", response.body)
131
+ end
132
+ end
133
+
134
+ def test_post_ps_scale_type_not_found
135
+ assert_raises(Azuki::API::Errors::RequestFailed) do
136
+ with_app('stack' => 'cedar') do |app_data|
137
+ azuki.post_ps_scale(app_data['name'], 'run', 2)
138
+ end
139
+ end
140
+ end
141
+
142
+ def test_post_ps_scale_up
143
+ with_app('stack' => 'cedar') do |app_data|
144
+ response = azuki.post_ps_scale(app_data['name'], 'web', 2)
145
+
146
+ assert_equal(200, response.status)
147
+ assert_equal("2", response.body)
148
+ end
149
+ end
150
+
151
+ def test_post_ps_scale_without_cedar
152
+ assert_raises(Azuki::API::Errors::RequestFailed) do
153
+ with_app do |app_data|
154
+ azuki.post_ps_scale(app_data['name'], 'web', 2)
155
+ end
156
+ end
157
+ end
158
+
159
+ def test_post_ps_stop
160
+ assert_raises(Azuki::API::Errors::RequestFailed) do
161
+ with_app do |app_data|
162
+ azuki.post_ps_stop(app_data['name'], {})
163
+ end
164
+ end
165
+ end
166
+
167
+ def test_post_ps_stop_with_ps
168
+ with_app do |app_data|
169
+ response = azuki.post_ps_stop(app_data['name'], 'ps' => 'web.1')
170
+
171
+ assert_equal(200, response.status)
172
+ assert_equal('ok', response.body)
173
+ end
174
+ end
175
+
176
+ def test_post_ps_stop_with_type
177
+ with_app do |app_data|
178
+ response = azuki.post_ps_stop(app_data['name'], 'type' => 'web')
179
+
180
+ assert_equal(200, response.status)
181
+ assert_equal('ok', response.body)
182
+ end
183
+ end
184
+
185
+ def test_post_ps_stop_app_not_found
186
+ assert_raises(Azuki::API::Errors::NotFound) do
187
+ azuki.post_ps_stop(random_name, {})
188
+ end
189
+ end
190
+
191
+ def test_put_dynos
192
+ with_app do |app_data|
193
+ dynos = 1
194
+ response = azuki.put_dynos(app_data['name'], dynos)
195
+
196
+ assert_equal(200, response.status)
197
+ assert_equal({
198
+ 'name' => app_data['name'],
199
+ 'dynos' => dynos
200
+ }, response.body)
201
+ end
202
+ end
203
+
204
+ def test_put_dynos_app_not_found
205
+ assert_raises(Azuki::API::Errors::NotFound) do
206
+ azuki.put_dynos(random_name, 1)
207
+ end
208
+ end
209
+
210
+ def test_put_dynos_with_cedar
211
+ assert_raises(Azuki::API::Errors::RequestFailed) do
212
+ with_app('stack' => 'cedar') do |app_data|
213
+ azuki.put_dynos(app_data['name'], 2)
214
+ end
215
+ end
216
+ end
217
+
218
+ def test_put_workers
219
+ with_app do |app_data|
220
+ workers = 1
221
+ response = azuki.put_workers(app_data['name'], workers)
222
+
223
+ assert_equal(200, response.status)
224
+ assert_equal({
225
+ 'name' => app_data['name'],
226
+ 'workers' => workers
227
+ }, response.body)
228
+ end
229
+ end
230
+
231
+ def test_put_workers_app_not_found
232
+ assert_raises(Azuki::API::Errors::NotFound) do
233
+ azuki.put_workers(random_name, 1)
234
+ end
235
+ end
236
+
237
+ def test_put_workers_with_cedar
238
+ assert_raises(Azuki::API::Errors::RequestFailed) do
239
+ with_app('stack' => 'cedar') do |app_data|
240
+ azuki.put_workers(app_data['name'], 2)
241
+ end
242
+ end
243
+ end
244
+
245
+ end