Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 59 lines (49 sloc) 1.751 kB
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
1 require_relative 'test_helper'
2
3 class ProvisionTest < Addons::Client::TestCase
4 def setup
33b2c8f @csquared update client/cli to reflect readme
csquared authored
5 ENV["ADDONS_API_URL"] = 'https://foo:bar@heroku.com/api/1/resources'
9aef165 @csquared refactor tests and set consumer_id on provision
csquared authored
6 stub_request(:any, target_url)
31777f4 @csquared stub CLI puts
csquared authored
7 stub(Addons::CLI).puts
33b2c8f @csquared update client/cli to reflect readme
csquared authored
8 @client = Addons::Client.new
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
9 end
10
9aef165 @csquared refactor tests and set consumer_id on provision
csquared authored
11 def target_url
33b2c8f @csquared update client/cli to reflect readme
csquared authored
12 ENV["ADDONS_API_URL"]
9aef165 @csquared refactor tests and set consumer_id on provision
csquared authored
13 end
14
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
15 def test_provisions_from_cmd_line
16 addons_client! "provision memcache:5mb"
17 assert_requested(:post, target_url,
18 body: { addon: 'memcache', plan: '5mb',
19 consumer_id: 'api-client@localhost'})
20 end
21
22 def test_provisions_from_ruby
23 @client.provision! 'foo:plizzan'
24 assert_requested(:post, target_url,
25 body: { addon: 'foo', plan: 'plizzan',
26 consumer_id: 'api-client@localhost'})
27 end
28
29 def test_sets_consumer_id
9aef165 @csquared refactor tests and set consumer_id on provision
csquared authored
30 @client.provision! 'foo:bar', :consumer_id => 'app123@heroku.com'
31 assert_requested(:post, target_url,
32 body: { addon: 'foo', plan: 'bar',
33 consumer_id: 'app123@heroku.com'})
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
34 end
35
9c6ca07 @csquared pass command line options through
csquared authored
36 def test_client_sets_provision_options
b1f6443 @csquared just need to work out host and port
csquared authored
37 @client.provision! 'foo:bar',
38 :consumer_id => 'app123@heroku.com',
39 :options => { :foo => 'bar', 'baz' => 'test' }
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
40
b1f6443 @csquared just need to work out host and port
csquared authored
41 assert_requested(:post, target_url,
42 body: { addon: 'foo', plan: 'bar',
43 consumer_id: 'app123@heroku.com',
44 options: { foo: 'bar', baz: 'test'}})
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
45 end
9c6ca07 @csquared pass command line options through
csquared authored
46
47 def test_cmd_line_sets_provision_options
48 addons_client! "provision foo:bar --options.foo=bar --options.baz=test --consumer_id=app123@heroku.com"
49
50 assert_requested(:post, target_url,
51 body: { addon: 'foo', plan: 'bar',
52 consumer_id: 'app123@heroku.com',
53 options: { foo: 'bar', baz: 'test'}})
31777f4 @csquared stub CLI puts
csquared authored
54 assert_received(Addons::CLI) do |cli|
55 cli.puts "Provisioned foo:bar"
56 end
9c6ca07 @csquared pass command line options through
csquared authored
57 end
0f4c4cf @csquared first tests for provisioning localhost
csquared authored
58 end
Something went wrong with that request. Please try again.