solusvm 2.0.0.beta2 → 2.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f5525c9a9ca9993cf379b33d2fd8dea7703202f
4
- data.tar.gz: c3573a14598c88ba6580b3aae59b90d05a253dd7
3
+ metadata.gz: d7b577a2b2f0d9e3d4d4a8f2f69316b7e607a150
4
+ data.tar.gz: abc92d8690f985cce76be047e74d095aeff3a47f
5
5
  SHA512:
6
- metadata.gz: baa5a2ed6befc61fd612e9f00f0f2c1e48ec4e73418fa1eceb1471a6a83e4553760adc75cd1ad5bb7a64a7a4e232f8a30decd507b7b86b37dcbe884504b547ba
7
- data.tar.gz: d7ffb735a072023886f597860cf71fd2b3cafa9d998af405314d2e314fd245b833d69fa7587527b3fd621dd9e925193eed37c4b94c6578c09502a7f15384203a
6
+ metadata.gz: 91c838d21eec7df5b22203874694bab4f0cfaa170d41273dc56bd1c4f47bd37021266b5e15316d1cfa33bc7741cf3f20b7a46a6a2913e212587987bb35081020
7
+ data.tar.gz: c6d613db43540b0bbf1c67cbbc6f8dd9c914e846e5207bea945e22f568b22fcaac63b7b3761ba51a0cb093a52e2755e8388ef82fe94f1f558d33d2793b5bc37e
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
- require 'rake-tomdoc'
4
+ require 'rake-tomdoc' unless RUBY_PLATFORM == 'java'
5
5
 
6
6
  Rake::TestTask.new(:test) do |test|
7
7
  test.libs << 'lib' << 'test'
data/lib/solusvm.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'json'
2
3
 
3
4
  require 'solusvm/hash'
4
5
  require 'solusvm/errors'
@@ -56,9 +56,9 @@ module SolusVM
56
56
  output api.change_hostname(vserverid, newhostname)
57
57
  end
58
58
 
59
- desc "addip VSERVERID", "Adds an ip to the server"
60
- def addip(vserverid)
61
- output api.add_ip(vserverid)
59
+ desc "addip VSERVERID [ip]", "Adds an ip to the server"
60
+ def addip(vserverid, ip = nil)
61
+ output api.add_ip(vserverid, ip)
62
62
  end
63
63
 
64
64
  desc "boot VSERVERID", "Boots up a server"
@@ -170,10 +170,11 @@ module SolusVM
170
170
  # Public: Adds an IP address for a specific server.
171
171
  #
172
172
  # vid - The virtual server ID in SolusVM
173
+ # ip - Specific IPv4 address to add (optional)
173
174
  #
174
175
  # Returns the IP as a String.
175
- def add_ip(vid)
176
- perform_request(action: 'vserver-addip', vserverid: vid)
176
+ def add_ip(vid, ip = nil)
177
+ perform_request(action: 'vserver-addip', vserverid: vid, ipv4addr: ip)
177
178
  returned_parameters['ipaddress']
178
179
  end
179
180
 
@@ -1,3 +1,3 @@
1
1
  module SolusVM
2
- VERSION = "2.0.0.beta2"
2
+ VERSION = "2.0.0.beta4"
3
3
  end
@@ -27,16 +27,18 @@ class TestClientCLI < Test::Unit::TestCase
27
27
  end
28
28
  SolusVM::Client.expects(:new).with(solusvm_params).returns(api)
29
29
 
30
- $stdout.expects(:puts).with("theresult")
31
- SolusVM::CLI.start(cli_expand_base_arguments([
32
- "client", "create",
33
- "--username", "theusername",
34
- "--password", "thepassword",
35
- "--email", "theemail",
36
- "--firstname", "thefirstname",
37
- "--lastname", "thelastname",
38
- "--company", "thecompany"
39
- ]))
30
+ out = capture_stdout do
31
+ SolusVM::CLI.start(cli_expand_base_arguments([
32
+ "client", "create",
33
+ "--username", "theusername",
34
+ "--password", "thepassword",
35
+ "--email", "theemail",
36
+ "--firstname", "thefirstname",
37
+ "--lastname", "thelastname",
38
+ "--company", "thecompany"
39
+ ]))
40
+ end
41
+ assert_match "theresult", out.string
40
42
  end
41
43
 
42
44
  def test_should_delegate_client_change_password_to_client
@@ -45,8 +47,10 @@ class TestClientCLI < Test::Unit::TestCase
45
47
  expects(:change_password).with("theusername", "thepassword").returns("theresult")
46
48
  end)
47
49
 
48
- $stdout.expects(:puts).with("theresult")
49
- SolusVM::CLI.start(cli_expand_base_arguments(["client", "change-password", "theusername", "thepassword"]))
50
+ out = capture_stdout do
51
+ SolusVM::CLI.start(cli_expand_base_arguments(["client", "change-password", "theusername", "thepassword"]))
52
+ end
53
+ assert_match "theresult", out.string
50
54
  end
51
55
 
52
56
  def test_should_delegate_client_authenticate_to_client
@@ -55,8 +59,10 @@ class TestClientCLI < Test::Unit::TestCase
55
59
  expects(:authenticate).with("theusername", "thepassword").returns("theresult")
56
60
  end)
57
61
 
58
- $stdout.expects(:puts).with("theresult")
59
- SolusVM::CLI.start(cli_expand_base_arguments(["client", "authenticate", "theusername", "thepassword"]))
62
+ out = capture_stdout do
63
+ SolusVM::CLI.start(cli_expand_base_arguments(["client", "authenticate", "theusername", "thepassword"]))
64
+ end
65
+ assert_match "theresult", out.string
60
66
  end
61
67
 
62
68
  def test_should_delegate_client_check_exists_to_client
@@ -65,8 +71,10 @@ class TestClientCLI < Test::Unit::TestCase
65
71
  expects(:exists?).with("theusername").returns("theresult")
66
72
  end)
67
73
 
68
- $stdout.expects(:puts).with("theresult")
69
- SolusVM::CLI.start(cli_expand_base_arguments(["client", "check-exists", "theusername"]))
74
+ out = capture_stdout do
75
+ SolusVM::CLI.start(cli_expand_base_arguments(["client", "check-exists", "theusername"]))
76
+ end
77
+ assert_match "theresult", out.string
70
78
  end
71
79
 
72
80
  def test_should_delegate_client_delete_to_client
@@ -75,8 +83,10 @@ class TestClientCLI < Test::Unit::TestCase
75
83
  expects(:delete).with("theusername").returns("theresult")
76
84
  end)
77
85
 
78
- $stdout.expects(:puts).with("theresult")
79
- SolusVM::CLI.start(cli_expand_base_arguments(["client", "delete", "theusername"]))
86
+ out = capture_stdout do
87
+ SolusVM::CLI.start(cli_expand_base_arguments(["client", "delete", "theusername"]))
88
+ end
89
+ assert_match "theresult", out.string
80
90
  end
81
91
 
82
92
  def test_should_delegate_client_list_to_client
@@ -85,7 +95,9 @@ class TestClientCLI < Test::Unit::TestCase
85
95
  expects(:list).returns("theresult")
86
96
  end)
87
97
 
88
- $stdout.expects(:puts).with("theresult")
89
- SolusVM::CLI.start(cli_expand_base_arguments(["client", "list"]))
98
+ out = capture_stdout do
99
+ SolusVM::CLI.start(cli_expand_base_arguments(["client", "list"]))
100
+ end
101
+ assert_match "theresult", out.string
90
102
  end
91
103
  end
@@ -15,8 +15,10 @@ class TestGeneralCLI < Test::Unit::TestCase
15
15
  expects(:templates).with("type").returns("thetemplates")
16
16
  end)
17
17
 
18
- $stdout.expects(:puts).with("thetemplates")
19
- SolusVM::CLI.start(cli_expand_base_arguments(["general", "templates", "type"]))
18
+ out = capture_stdout do
19
+ SolusVM::CLI.start(cli_expand_base_arguments(["general", "templates", "type"]))
20
+ end
21
+ assert_match "thetemplates", out.string
20
22
  end
21
23
 
22
24
  def test_should_delegate_plans_to_general
@@ -25,8 +27,10 @@ class TestGeneralCLI < Test::Unit::TestCase
25
27
  expects(:plans).with("type").returns("theplans")
26
28
  end)
27
29
 
28
- $stdout.expects(:puts).with("theplans")
29
- SolusVM::CLI.start(cli_expand_base_arguments(["general", "plans", "type"]))
30
+ out = capture_stdout do
31
+ SolusVM::CLI.start(cli_expand_base_arguments(["general", "plans", "type"]))
32
+ end
33
+ assert_match "theplans", out.string
30
34
  end
31
35
 
32
36
  def test_should_delegate_isos_to_general
@@ -35,7 +39,9 @@ class TestGeneralCLI < Test::Unit::TestCase
35
39
  expects(:isos).with("type").returns("theisos")
36
40
  end)
37
41
 
38
- $stdout.expects(:puts).with("theisos")
39
- SolusVM::CLI.start(cli_expand_base_arguments(["general", "isos", "type"]))
42
+ out = capture_stdout do
43
+ SolusVM::CLI.start(cli_expand_base_arguments(["general", "isos", "type"]))
44
+ end
45
+ assert_match "theisos", out.string
40
46
  end
41
47
  end
@@ -15,8 +15,10 @@ class TestNodeCLI < Test::Unit::TestCase
15
15
  expects(:available_ips).with("thevserverid").returns("theips")
16
16
  end)
17
17
 
18
- $stdout.expects(:puts).with("theips")
19
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "available-ips", "thevserverid"]))
18
+ out = capture_stdout do
19
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "available-ips", "thevserverid"]))
20
+ end
21
+ assert_match "theips", out.string
20
22
  end
21
23
 
22
24
  def test_should_delegate_node_stats_to_node
@@ -25,8 +27,10 @@ class TestNodeCLI < Test::Unit::TestCase
25
27
  expects(:statistics).with("thevserverid").returns("thestats")
26
28
  end)
27
29
 
28
- $stdout.expects(:puts).with("thestats")
29
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "stats", "thevserverid"]))
30
+ out = capture_stdout do
31
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "stats", "thevserverid"]))
32
+ end
33
+ assert_match "thestats", out.string
30
34
  end
31
35
 
32
36
  def test_should_delegate_node_xenresources_to_node
@@ -35,8 +39,10 @@ class TestNodeCLI < Test::Unit::TestCase
35
39
  expects(:xenresources).with("thevserverid").returns("theresources")
36
40
  end)
37
41
 
38
- $stdout.expects(:puts).with("theresources")
39
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "xenresources", "thevserverid"]))
42
+ out = capture_stdout do
43
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "xenresources", "thevserverid"]))
44
+ end
45
+ assert_match "theresources", out.string
40
46
  end
41
47
 
42
48
  def test_should_delegate_node_virtualservers_to_node
@@ -45,8 +51,10 @@ class TestNodeCLI < Test::Unit::TestCase
45
51
  expects(:virtualservers).with("thevserverid").returns("thedata")
46
52
  end)
47
53
 
48
- $stdout.expects(:puts).with("thedata")
49
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "virtualservers", "thevserverid"]))
54
+ out = capture_stdout do
55
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "virtualservers", "thevserverid"]))
56
+ end
57
+ assert_match "thedata", out.string
50
58
  end
51
59
 
52
60
  def test_should_delegate_nodes_list_to_node
@@ -55,8 +63,10 @@ class TestNodeCLI < Test::Unit::TestCase
55
63
  expects(:list).with("type").returns("thenodes")
56
64
  end)
57
65
 
58
- $stdout.expects(:puts).with("thenodes")
59
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "list", "type"]))
66
+ out = capture_stdout do
67
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "list", "type"]))
68
+ end
69
+ assert_match "thenodes", out.string
60
70
  end
61
71
 
62
72
  def test_should_delegate_nodes_ids_to_node
@@ -65,8 +75,10 @@ class TestNodeCLI < Test::Unit::TestCase
65
75
  expects(:ids).with("type").returns("thenodes")
66
76
  end)
67
77
 
68
- $stdout.expects(:puts).with("thenodes")
69
- SolusVM::CLI.start(cli_expand_base_arguments(["node", "list-ids", "type"]))
78
+ out = capture_stdout do
79
+ SolusVM::CLI.start(cli_expand_base_arguments(["node", "list-ids", "type"]))
80
+ end
81
+ assert_match "thenodes", out.string
70
82
  end
71
83
 
72
84
  end
@@ -41,31 +41,33 @@ class TestResellerCLI < Test::Unit::TestCase
41
41
  end.returns("theresult")
42
42
  end)
43
43
 
44
- $stdout.expects(:puts).with("theresult")
45
- SolusVM::CLI.start(cli_expand_base_arguments([
46
- "reseller", "create",
47
- "--username", "theusername",
48
- "--password", "thepassword",
49
- "--email", "theemail",
50
- "--firstname", "thefirstname",
51
- "--lastname", "thelastname",
52
- "--company", "thecompany",
53
- "--usernameprefix", "theusernameprefix",
54
- "--maxvps", "themaxvps",
55
- "--maxusers", "themaxusers",
56
- "--maxmem", "themaxmem",
57
- "--maxburst", "themaxburst",
58
- "--maxdisk", "themaxdisk",
59
- "--maxbw", "themaxbw",
60
- "--maxipv4", "themaxipv4",
61
- "--maxipv6", "themaxipv6",
62
- "--nodegroups", "thenodegroups",
63
- "--mediagroups", "themediagroups",
64
- "--openvz", "theopenvz",
65
- "--xenpv", "thexenpv",
66
- "--xenhvm", "thexenhvm",
67
- "--kvm", "thekvm"
68
- ]))
44
+ out = capture_stdout do
45
+ SolusVM::CLI.start(cli_expand_base_arguments([
46
+ "reseller", "create",
47
+ "--username", "theusername",
48
+ "--password", "thepassword",
49
+ "--email", "theemail",
50
+ "--firstname", "thefirstname",
51
+ "--lastname", "thelastname",
52
+ "--company", "thecompany",
53
+ "--usernameprefix", "theusernameprefix",
54
+ "--maxvps", "themaxvps",
55
+ "--maxusers", "themaxusers",
56
+ "--maxmem", "themaxmem",
57
+ "--maxburst", "themaxburst",
58
+ "--maxdisk", "themaxdisk",
59
+ "--maxbw", "themaxbw",
60
+ "--maxipv4", "themaxipv4",
61
+ "--maxipv6", "themaxipv6",
62
+ "--nodegroups", "thenodegroups",
63
+ "--mediagroups", "themediagroups",
64
+ "--openvz", "theopenvz",
65
+ "--xenpv", "thexenpv",
66
+ "--xenhvm", "thexenhvm",
67
+ "--kvm", "thekvm"
68
+ ]))
69
+ end
70
+ assert_match "theresult", out.string
69
71
  end
70
72
 
71
73
  def test_should_delegate_reseller_change_resources_to_reseller
@@ -93,24 +95,26 @@ class TestResellerCLI < Test::Unit::TestCase
93
95
  end.returns("theresult")
94
96
  end)
95
97
 
96
- $stdout.expects(:puts).with("theresult")
97
- SolusVM::CLI.start(cli_expand_base_arguments([
98
- "reseller", "change-resources",
99
- "--maxvps", "themaxvps",
100
- "--maxusers", "themaxusers",
101
- "--maxmem", "themaxmem",
102
- "--maxburst", "themaxburst",
103
- "--maxdisk", "themaxdisk",
104
- "--maxbw", "themaxbw",
105
- "--maxipv4", "themaxipv4",
106
- "--maxipv6", "themaxipv6",
107
- "--nodegroups", "thenodegroups",
108
- "--mediagroups", "themediagroups",
109
- "--openvz", "theopenvz",
110
- "--xenpv", "thexenpv",
111
- "--xenhvm", "thexenhvm",
112
- "--kvm", "thekvm"
113
- ]))
98
+ out = capture_stdout do
99
+ SolusVM::CLI.start(cli_expand_base_arguments([
100
+ "reseller", "change-resources",
101
+ "--maxvps", "themaxvps",
102
+ "--maxusers", "themaxusers",
103
+ "--maxmem", "themaxmem",
104
+ "--maxburst", "themaxburst",
105
+ "--maxdisk", "themaxdisk",
106
+ "--maxbw", "themaxbw",
107
+ "--maxipv4", "themaxipv4",
108
+ "--maxipv6", "themaxipv6",
109
+ "--nodegroups", "thenodegroups",
110
+ "--mediagroups", "themediagroups",
111
+ "--openvz", "theopenvz",
112
+ "--xenpv", "thexenpv",
113
+ "--xenhvm", "thexenhvm",
114
+ "--kvm", "thekvm"
115
+ ]))
116
+ end
117
+ assert_match "theresult", out.string
114
118
  end
115
119
 
116
120
  def test_should_delegate_reseller_info_to_reseller
@@ -119,8 +123,10 @@ class TestResellerCLI < Test::Unit::TestCase
119
123
  expects(:info).with("theusername").returns("theresult")
120
124
  end)
121
125
 
122
- $stdout.expects(:puts).with("theresult")
123
- SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "info", "theusername"]))
126
+ out = capture_stdout do
127
+ SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "info", "theusername"]))
128
+ end
129
+ assert_match "theresult", out.string
124
130
  end
125
131
 
126
132
  def test_should_delegate_reseller_delete_to_reseller
@@ -129,8 +135,10 @@ class TestResellerCLI < Test::Unit::TestCase
129
135
  expects(:delete).with("theusername").returns("theresult")
130
136
  end)
131
137
 
132
- $stdout.expects(:puts).with("theresult")
133
- SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "delete", "theusername"]))
138
+ out = capture_stdout do
139
+ SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "delete", "theusername"]))
140
+ end
141
+ assert_match "theresult", out.string
134
142
  end
135
143
 
136
144
  def test_should_delegate_reseller_list_to_reseller
@@ -139,7 +147,9 @@ class TestResellerCLI < Test::Unit::TestCase
139
147
  expects(:list).returns("theresult")
140
148
  end)
141
149
 
142
- $stdout.expects(:puts).with("theresult")
143
- SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "list"]))
150
+ out = capture_stdout do
151
+ SolusVM::CLI.start(cli_expand_base_arguments(["reseller", "list"]))
152
+ end
153
+ assert_match "theresult", out.string
144
154
  end
145
155
  end
@@ -16,8 +16,10 @@ class TestServerCLI < Test::Unit::TestCase
16
16
  expects(:status).with("thevserverid").returns("theresult")
17
17
  end)
18
18
 
19
- $stdout.expects(:puts).with("theresult")
20
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "status", "thevserverid"]))
19
+ out = capture_stdout do
20
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "status", "thevserverid"]))
21
+ end
22
+ assert_match "theresult", out.string
21
23
  end
22
24
 
23
25
  def test_should_delegate_server_change_plan_to_server
@@ -26,8 +28,10 @@ class TestServerCLI < Test::Unit::TestCase
26
28
  expects(:change_plan).with("thevserverid", "thenewplan").returns("theresult")
27
29
  end)
28
30
 
29
- $stdout.expects(:puts).with("theresult")
30
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-plan", "thevserverid", "thenewplan"]))
31
+ out = capture_stdout do
32
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-plan", "thevserverid", "thenewplan"]))
33
+ end
34
+ assert_match "theresult", out.string
31
35
  end
32
36
 
33
37
  def test_should_delegate_server_change_owner_to_server
@@ -36,8 +40,10 @@ class TestServerCLI < Test::Unit::TestCase
36
40
  expects(:change_owner).with("thevserverid", "thenewowner").returns("theresult")
37
41
  end)
38
42
 
39
- $stdout.expects(:puts).with("theresult")
40
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-owner", "thevserverid", "thenewowner"]))
43
+ out = capture_stdout do
44
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-owner", "thevserverid", "thenewowner"]))
45
+ end
46
+ assert_match "theresult", out.string
41
47
  end
42
48
 
43
49
  def test_should_delegate_server_change_vncpass_to_server
@@ -46,8 +52,10 @@ class TestServerCLI < Test::Unit::TestCase
46
52
  expects(:change_vncpass).with("thevserverid", "thenewpass").returns("theresult")
47
53
  end)
48
54
 
49
- $stdout.expects(:puts).with("theresult")
50
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-vncpass", "thevserverid", "thenewpass"]))
55
+ out = capture_stdout do
56
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-vncpass", "thevserverid", "thenewpass"]))
57
+ end
58
+ assert_match "theresult", out.string
51
59
  end
52
60
 
53
61
  def test_should_delegate_server_change_rootpass_to_server
@@ -56,8 +64,10 @@ class TestServerCLI < Test::Unit::TestCase
56
64
  expects(:change_rootpassword).with("thevserverid", "thenewpass").returns("theresult")
57
65
  end)
58
66
 
59
- $stdout.expects(:puts).with("theresult")
60
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-rootpass", "thevserverid", "thenewpass"]))
67
+ out = capture_stdout do
68
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-rootpass", "thevserverid", "thenewpass"]))
69
+ end
70
+ assert_match "theresult", out.string
61
71
  end
62
72
 
63
73
  def test_should_delegate_server_change_bootorder_to_server
@@ -66,8 +76,10 @@ class TestServerCLI < Test::Unit::TestCase
66
76
  expects(:change_bootorder).with("thevserverid", "theneworder").returns("theresult")
67
77
  end)
68
78
 
69
- $stdout.expects(:puts).with("theresult")
70
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-bootorder", "thevserverid", "theneworder"]))
79
+ out = capture_stdout do
80
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-bootorder", "thevserverid", "theneworder"]))
81
+ end
82
+ assert_match "theresult", out.string
71
83
  end
72
84
 
73
85
  def test_should_delegate_server_change_hostname_to_server
@@ -76,18 +88,22 @@ class TestServerCLI < Test::Unit::TestCase
76
88
  expects(:change_hostname).with("thevserverid", "thenewhostname").returns("theresult")
77
89
  end)
78
90
 
79
- $stdout.expects(:puts).with("theresult")
80
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-hostname", "thevserverid", "thenewhostname"]))
91
+ out = capture_stdout do
92
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "change-hostname", "thevserverid", "thenewhostname"]))
93
+ end
94
+ assert_match "theresult", out.string
81
95
  end
82
96
 
83
97
  def test_should_delegate_server_add_ip_to_server
84
98
  SolusVM::Server.stubs(:new).with(@solusvm_params).returns(mock do
85
99
  expects(:successful?).returns(true)
86
- expects(:add_ip).with("thevserverid").returns("theresult")
100
+ expects(:add_ip).with("thevserverid", "ipv4addr").returns("theresult")
87
101
  end)
88
102
 
89
- $stdout.expects(:puts).with("theresult")
90
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "addip", "thevserverid"]))
103
+ out = capture_stdout do
104
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "addip", "thevserverid", "ipv4addr"]))
105
+ end
106
+ assert_match "theresult", out.string
91
107
  end
92
108
 
93
109
  def test_should_delegate_server_boot_to_server
@@ -96,8 +112,10 @@ class TestServerCLI < Test::Unit::TestCase
96
112
  expects(:boot).with("thevserverid").returns("theresult")
97
113
  end)
98
114
 
99
- $stdout.expects(:puts).with("theresult")
100
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "boot", "thevserverid"]))
115
+ out = capture_stdout do
116
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "boot", "thevserverid"]))
117
+ end
118
+ assert_match "theresult", out.string
101
119
  end
102
120
 
103
121
  def test_should_delegate_server_reboot_to_server
@@ -106,8 +124,10 @@ class TestServerCLI < Test::Unit::TestCase
106
124
  expects(:reboot).with("thevserverid").returns("theresult")
107
125
  end)
108
126
 
109
- $stdout.expects(:puts).with("theresult")
110
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "reboot", "thevserverid"]))
127
+ out = capture_stdout do
128
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "reboot", "thevserverid"]))
129
+ end
130
+ assert_match "theresult", out.string
111
131
  end
112
132
 
113
133
  def test_should_delegate_server_shutdown_to_server
@@ -116,8 +136,10 @@ class TestServerCLI < Test::Unit::TestCase
116
136
  expects(:shutdown).with("thevserverid").returns("theresult")
117
137
  end)
118
138
 
119
- $stdout.expects(:puts).with("theresult")
120
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "shutdown", "thevserverid"]))
139
+ out = capture_stdout do
140
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "shutdown", "thevserverid"]))
141
+ end
142
+ assert_match "theresult", out.string
121
143
  end
122
144
 
123
145
  def test_should_delegate_server_suspend_to_server
@@ -126,8 +148,10 @@ class TestServerCLI < Test::Unit::TestCase
126
148
  expects(:suspend).with("thevserverid").returns("theresult")
127
149
  end)
128
150
 
129
- $stdout.expects(:puts).with("theresult")
130
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "suspend", "thevserverid"]))
151
+ out = capture_stdout do
152
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "suspend", "thevserverid"]))
153
+ end
154
+ assert_match "theresult", out.string
131
155
  end
132
156
 
133
157
  def test_should_delegate_server_resume_to_server
@@ -136,8 +160,10 @@ class TestServerCLI < Test::Unit::TestCase
136
160
  expects(:resume).with("thevserverid").returns("theresult")
137
161
  end)
138
162
 
139
- $stdout.expects(:puts).with("theresult")
140
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "resume", "thevserverid"]))
163
+ out = capture_stdout do
164
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "resume", "thevserverid"]))
165
+ end
166
+ assert_match "theresult", out.string
141
167
  end
142
168
 
143
169
  def test_should_delegate_server_check_exists_to_server
@@ -146,8 +172,10 @@ class TestServerCLI < Test::Unit::TestCase
146
172
  expects(:exists?).with("thevserverid").returns("theresult")
147
173
  end)
148
174
 
149
- $stdout.expects(:puts).with("theresult")
150
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "check-exists", "thevserverid"]))
175
+ out = capture_stdout do
176
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "check-exists", "thevserverid"]))
177
+ end
178
+ assert_match "theresult", out.string
151
179
  end
152
180
 
153
181
  def test_should_delegate_server_terminate_to_server
@@ -156,8 +184,10 @@ class TestServerCLI < Test::Unit::TestCase
156
184
  expects(:terminate).with("thevserverid").returns("theresult")
157
185
  end)
158
186
 
159
- $stdout.expects(:puts).with("theresult")
160
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "terminate", "thevserverid"]))
187
+ out = capture_stdout do
188
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "terminate", "thevserverid"]))
189
+ end
190
+ assert_match "theresult", out.string
161
191
  end
162
192
 
163
193
  def test_should_delegate_server_rebuild_to_server
@@ -166,8 +196,10 @@ class TestServerCLI < Test::Unit::TestCase
166
196
  expects(:rebuild).with("thevserverid", template: "thetemplate").returns("theresult")
167
197
  end)
168
198
 
169
- $stdout.expects(:puts).with("theresult")
170
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "rebuild", "thevserverid", "--template", "thetemplate"]))
199
+ out = capture_stdout do
200
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "rebuild", "thevserverid", "--template", "thetemplate"]))
201
+ end
202
+ assert_match "theresult", out.string
171
203
  end
172
204
 
173
205
  def test_should_delegate_server_tun_switcher_on_to_server
@@ -176,8 +208,10 @@ class TestServerCLI < Test::Unit::TestCase
176
208
  expects(:tun_enable).with("thevserverid").returns("theresult")
177
209
  end)
178
210
 
179
- $stdout.expects(:puts).with("theresult")
180
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "on"]))
211
+ out = capture_stdout do
212
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "on"]))
213
+ end
214
+ assert_match "theresult", out.string
181
215
  end
182
216
 
183
217
  def test_should_delegate_server_tun_switcher_off_to_server
@@ -186,8 +220,10 @@ class TestServerCLI < Test::Unit::TestCase
186
220
  expects(:tun_disable).with("thevserverid").returns("theresult")
187
221
  end)
188
222
 
189
- $stdout.expects(:puts).with("theresult")
190
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "off"]))
223
+ out = capture_stdout do
224
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "tun-switcher", "thevserverid", "off"]))
225
+ end
226
+ assert_match "theresult", out.string
191
227
  end
192
228
 
193
229
  def test_should_delegate_server_network_switcher_on_to_server
@@ -196,8 +232,10 @@ class TestServerCLI < Test::Unit::TestCase
196
232
  expects(:network_enable).with("thevserverid").returns("theresult")
197
233
  end)
198
234
 
199
- $stdout.expects(:puts).with("theresult")
200
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "on"]))
235
+ out = capture_stdout do
236
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "on"]))
237
+ end
238
+ assert_match "theresult", out.string
201
239
  end
202
240
 
203
241
  def test_should_delegate_server_network_switcher_off_to_server
@@ -206,8 +244,10 @@ class TestServerCLI < Test::Unit::TestCase
206
244
  expects(:network_disable).with("thevserverid").returns("theresult")
207
245
  end)
208
246
 
209
- $stdout.expects(:puts).with("theresult")
210
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "off"]))
247
+ out = capture_stdout do
248
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "network-switcher", "thevserverid", "off"]))
249
+ end
250
+ assert_match "theresult", out.string
211
251
  end
212
252
 
213
253
  def test_should_delegate_server_pae_switcher_on_to_server
@@ -216,8 +256,10 @@ class TestServerCLI < Test::Unit::TestCase
216
256
  expects(:pae_enable).with("thevserverid").returns("theresult")
217
257
  end)
218
258
 
219
- $stdout.expects(:puts).with("theresult")
220
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "on"]))
259
+ out = capture_stdout do
260
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "on"]))
261
+ end
262
+ assert_match "theresult", out.string
221
263
  end
222
264
 
223
265
  def test_should_delegate_server_pae_switcher_off_to_server
@@ -226,8 +268,10 @@ class TestServerCLI < Test::Unit::TestCase
226
268
  expects(:pae_disable).with("thevserverid").returns("theresult")
227
269
  end)
228
270
 
229
- $stdout.expects(:puts).with("theresult")
230
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "off"]))
271
+ out = capture_stdout do
272
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "pae-switcher", "thevserverid", "off"]))
273
+ end
274
+ assert_match "theresult", out.string
231
275
  end
232
276
 
233
277
  def test_should_delegate_server_info_to_server
@@ -236,8 +280,10 @@ class TestServerCLI < Test::Unit::TestCase
236
280
  expects(:info).with("thevserverid").returns("theresult")
237
281
  end)
238
282
 
239
- $stdout.expects(:puts).with("theresult")
240
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "info", "thevserverid"]))
283
+ out = capture_stdout do
284
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "info", "thevserverid"]))
285
+ end
286
+ assert_match "theresult", out.string
241
287
  end
242
288
 
243
289
  def test_should_delegate_server_vnc_to_server
@@ -246,8 +292,10 @@ class TestServerCLI < Test::Unit::TestCase
246
292
  expects(:vnc).with("thevserverid").returns("theresult")
247
293
  end)
248
294
 
249
- $stdout.expects(:puts).with("theresult")
250
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "vnc", "thevserverid"]))
295
+ out = capture_stdout do
296
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "vnc", "thevserverid"]))
297
+ end
298
+ assert_match "theresult", out.string
251
299
  end
252
300
 
253
301
  def test_should_delegate_server_console_to_server
@@ -256,8 +304,10 @@ class TestServerCLI < Test::Unit::TestCase
256
304
  expects(:console).with("thevserverid").returns("theresult")
257
305
  end)
258
306
 
259
- $stdout.expects(:puts).with("theresult")
260
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "console", "thevserverid"]))
307
+ out = capture_stdout do
308
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "console", "thevserverid"]))
309
+ end
310
+ assert_match "theresult", out.string
261
311
  end
262
312
 
263
313
  def test_should_delegate_server_info_all_to_server
@@ -266,8 +316,10 @@ class TestServerCLI < Test::Unit::TestCase
266
316
  expects(:info_all).with("thevserverid").returns("theresult")
267
317
  end)
268
318
 
269
- $stdout.expects(:puts).with("theresult")
270
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "info-all", "thevserverid"]))
319
+ out = capture_stdout do
320
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "info-all", "thevserverid"]))
321
+ end
322
+ assert_match "theresult", out.string
271
323
  end
272
324
 
273
325
  def test_should_delegate_server_mountiso_to_server
@@ -276,8 +328,10 @@ class TestServerCLI < Test::Unit::TestCase
276
328
  expects(:mountiso).with("thevserverid", "theiso").returns("theresult")
277
329
  end)
278
330
 
279
- $stdout.expects(:puts).with("theresult")
280
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "mountiso", "thevserverid", "theiso"]))
331
+ out = capture_stdout do
332
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "mountiso", "thevserverid", "theiso"]))
333
+ end
334
+ assert_match "theresult", out.string
281
335
  end
282
336
 
283
337
  def test_should_delegate_server_unmountiso_to_server
@@ -286,8 +340,10 @@ class TestServerCLI < Test::Unit::TestCase
286
340
  expects(:unmountiso).with("thevserverid").returns("theresult")
287
341
  end)
288
342
 
289
- $stdout.expects(:puts).with("theresult")
290
- SolusVM::CLI.start(cli_expand_base_arguments(["server", "unmountiso", "thevserverid"]))
343
+ out = capture_stdout do
344
+ SolusVM::CLI.start(cli_expand_base_arguments(["server", "unmountiso", "thevserverid"]))
345
+ end
346
+ assert_match "theresult", out.string
291
347
  end
292
348
 
293
349
  def test_should_delegate_server_create_to_server
@@ -300,17 +356,19 @@ class TestServerCLI < Test::Unit::TestCase
300
356
  ).returns("theresult")
301
357
  end)
302
358
 
303
- $stdout.expects(:puts).with("theresult")
304
- SolusVM::CLI.start(cli_expand_base_arguments([
305
- "server", "create",
306
- "thehostname",
307
- "thepassword",
308
- "--plan", "theplan",
309
- "--ips", "theips",
310
- "--kind", "thekind",
311
- "--username", "theusername",
312
- "--template", "thetemplate",
313
- "--node", "thenode"
314
- ]))
359
+ out = capture_stdout do
360
+ SolusVM::CLI.start(cli_expand_base_arguments([
361
+ "server", "create",
362
+ "thehostname",
363
+ "thepassword",
364
+ "--plan", "theplan",
365
+ "--ips", "theips",
366
+ "--kind", "thekind",
367
+ "--username", "theusername",
368
+ "--template", "thetemplate",
369
+ "--node", "thenode"
370
+ ]))
371
+ end
372
+ assert_match "theresult", out.string
315
373
  end
316
374
  end
@@ -10,8 +10,8 @@ class TestCLI < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_should_print_version
13
- $stdout.expects(:puts).with(SolusVM::VERSION)
14
- SolusVM::CLI.start %W(version)
13
+ out = capture_stdout { SolusVM::CLI.start %W(version) }
14
+ assert_match SolusVM::VERSION, out.string
15
15
  end
16
16
 
17
17
  end
@@ -146,6 +146,13 @@ class TestServer < Test::Unit::TestCase
146
146
  assert @server.successful?
147
147
  end
148
148
 
149
+ def test_add_specific_ip
150
+ stub_response 'server/add-ip'
151
+
152
+ assert_equal '123.123.123.123', @server.add_ip(1, '123.123.123.123')
153
+ assert @server.successful?
154
+ end
155
+
149
156
  def test_del_ip
150
157
  stub_response 'server/del-ip'
151
158
 
data/test/test_helper.rb CHANGED
@@ -1,9 +1,23 @@
1
+ require 'stringio'
1
2
  require 'test/unit'
2
3
  require 'solusvm'
3
4
  require 'mocha/setup'
4
5
  require 'sham_rack'
5
6
  require 'set'
6
- require 'json'
7
+
8
+ module Kernel
9
+ # Public: Redirect $stdout to an instance of StringIO.
10
+ #
11
+ # Returns the captured output as a StringIO.
12
+ def capture_stdout
13
+ out = StringIO.new
14
+ $stdout = out
15
+ yield
16
+ return out
17
+ ensure
18
+ $stdout = STDOUT
19
+ end
20
+ end
7
21
 
8
22
  class Test::Unit::TestCase
9
23
  # Public: Stubs a JSON reponse using ShamRack.
metadata CHANGED
@@ -1,127 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solusvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.1
19
+ version: 0.19.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.18.1
26
+ version: 0.19.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.9
33
+ version: 0.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.9
40
+ version: 0.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 10.1.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 10.1.1
69
- - !ruby/object:Gem::Dependency
70
- name: rake-tomdoc
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.0.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.0.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: sham_rack
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ~>
88
74
  - !ruby/object:Gem::Version
89
75
  version: 1.3.6
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ~>
95
81
  - !ruby/object:Gem::Version
96
82
  version: 1.3.6
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: sinatra
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - "~>"
87
+ - - ~>
102
88
  - !ruby/object:Gem::Version
103
89
  version: 1.4.4
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - "~>"
94
+ - - ~>
109
95
  - !ruby/object:Gem::Version
110
96
  version: 1.4.4
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: test-unit
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
- - - "~>"
101
+ - - ~>
116
102
  - !ruby/object:Gem::Version
117
103
  version: 2.5.5
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - ~>
123
109
  - !ruby/object:Gem::Version
124
110
  version: 2.5.5
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake-tomdoc
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.2
125
125
  description: SolusVM allows for easy interaction with the SolusVM Admin::API.
126
126
  email:
127
127
  - jmazzi@gmail.com
@@ -239,12 +239,12 @@ require_paths:
239
239
  - lib
240
240
  required_ruby_version: !ruby/object:Gem::Requirement
241
241
  requirements:
242
- - - ">="
242
+ - - '>='
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  requirements:
247
- - - ">"
247
+ - - '>'
248
248
  - !ruby/object:Gem::Version
249
249
  version: 1.3.1
250
250
  requirements: []