wavefront-cli 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +20 -0
  3. data/.gitignore +4 -0
  4. data/.travis.yml +16 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +65 -0
  7. data/README.md +221 -0
  8. data/Rakefile +18 -0
  9. data/bin/wavefront +14 -0
  10. data/lib/wavefront-cli/alert.rb +60 -0
  11. data/lib/wavefront-cli/base.rb +320 -0
  12. data/lib/wavefront-cli/cloudintegration.rb +12 -0
  13. data/lib/wavefront-cli/commands/alert.rb +38 -0
  14. data/lib/wavefront-cli/commands/base.rb +105 -0
  15. data/lib/wavefront-cli/commands/dashboard.rb +29 -0
  16. data/lib/wavefront-cli/commands/event.rb +44 -0
  17. data/lib/wavefront-cli/commands/integration.rb +33 -0
  18. data/lib/wavefront-cli/commands/link.rb +34 -0
  19. data/lib/wavefront-cli/commands/message.rb +23 -0
  20. data/lib/wavefront-cli/commands/metric.rb +20 -0
  21. data/lib/wavefront-cli/commands/proxy.rb +25 -0
  22. data/lib/wavefront-cli/commands/query.rb +32 -0
  23. data/lib/wavefront-cli/commands/savedsearch.rb +32 -0
  24. data/lib/wavefront-cli/commands/source.rb +27 -0
  25. data/lib/wavefront-cli/commands/user.rb +24 -0
  26. data/lib/wavefront-cli/commands/webhook.rb +25 -0
  27. data/lib/wavefront-cli/commands/window.rb +33 -0
  28. data/lib/wavefront-cli/commands/write.rb +35 -0
  29. data/lib/wavefront-cli/constants.rb +17 -0
  30. data/lib/wavefront-cli/controller.rb +134 -0
  31. data/lib/wavefront-cli/dashboard.rb +27 -0
  32. data/lib/wavefront-cli/display/alert.rb +44 -0
  33. data/lib/wavefront-cli/display/base.rb +304 -0
  34. data/lib/wavefront-cli/display/cloudintegration.rb +18 -0
  35. data/lib/wavefront-cli/display/dashboard.rb +21 -0
  36. data/lib/wavefront-cli/display/event.rb +19 -0
  37. data/lib/wavefront-cli/display/externallink.rb +13 -0
  38. data/lib/wavefront-cli/display/maintenancewindow.rb +19 -0
  39. data/lib/wavefront-cli/display/message.rb +8 -0
  40. data/lib/wavefront-cli/display/metric.rb +22 -0
  41. data/lib/wavefront-cli/display/proxy.rb +13 -0
  42. data/lib/wavefront-cli/display/query.rb +69 -0
  43. data/lib/wavefront-cli/display/savedsearch.rb +17 -0
  44. data/lib/wavefront-cli/display/source.rb +26 -0
  45. data/lib/wavefront-cli/display/user.rb +16 -0
  46. data/lib/wavefront-cli/display/webhook.rb +24 -0
  47. data/lib/wavefront-cli/display/write.rb +19 -0
  48. data/lib/wavefront-cli/event.rb +162 -0
  49. data/lib/wavefront-cli/exception.rb +5 -0
  50. data/lib/wavefront-cli/externallink.rb +16 -0
  51. data/lib/wavefront-cli/maintenancewindow.rb +16 -0
  52. data/lib/wavefront-cli/message.rb +19 -0
  53. data/lib/wavefront-cli/metric.rb +24 -0
  54. data/lib/wavefront-cli/opt_handler.rb +62 -0
  55. data/lib/wavefront-cli/proxy.rb +22 -0
  56. data/lib/wavefront-cli/query.rb +74 -0
  57. data/lib/wavefront-cli/savedsearch.rb +24 -0
  58. data/lib/wavefront-cli/source.rb +20 -0
  59. data/lib/wavefront-cli/user.rb +25 -0
  60. data/lib/wavefront-cli/version.rb +1 -0
  61. data/lib/wavefront-cli/webhook.rb +8 -0
  62. data/lib/wavefront-cli/write.rb +244 -0
  63. data/spec/spec_helper.rb +197 -0
  64. data/spec/wavefront-cli/alert_spec.rb +44 -0
  65. data/spec/wavefront-cli/base_spec.rb +47 -0
  66. data/spec/wavefront-cli/cli_help_spec.rb +47 -0
  67. data/spec/wavefront-cli/cloudintegration_spec.rb +24 -0
  68. data/spec/wavefront-cli/dashboard_spec.rb +37 -0
  69. data/spec/wavefront-cli/event_spec.rb +19 -0
  70. data/spec/wavefront-cli/externallink_spec.rb +18 -0
  71. data/spec/wavefront-cli/maintanancewindow_spec.rb +19 -0
  72. data/spec/wavefront-cli/message_spec.rb +28 -0
  73. data/spec/wavefront-cli/metric_spec.rb +22 -0
  74. data/spec/wavefront-cli/proxy_spec.rb +26 -0
  75. data/spec/wavefront-cli/query_spec.rb +63 -0
  76. data/spec/wavefront-cli/resources/conf.yaml +10 -0
  77. data/spec/wavefront-cli/savedsearch_spec.rb +18 -0
  78. data/spec/wavefront-cli/source_spec.rb +18 -0
  79. data/spec/wavefront-cli/user_spec.rb +31 -0
  80. data/spec/wavefront-cli/webhook_spec.rb +17 -0
  81. data/wavefront-cli.gemspec +36 -0
  82. metadata +279 -0
@@ -0,0 +1,197 @@
1
+ require 'webmock/minitest'
2
+ require 'spy/integration'
3
+ require 'inifile'
4
+ require 'minitest'
5
+ require 'minitest/autorun'
6
+ require 'minitest/spec'
7
+ require 'pathname'
8
+ require_relative '../lib/wavefront-cli/controller'
9
+
10
+ CMD = 'wavefront'.freeze
11
+ ENDPOINT = 'metrics.wavefront.com'
12
+ TOKEN = '0123456789-ABCDEF'
13
+ RES_DIR = Pathname.new(__FILE__).dirname + 'wavefront-cli' + 'resources'
14
+ CF = RES_DIR + 'conf.yaml'
15
+ CF_VAL = IniFile.load(CF)
16
+ JSON_POST_HEADERS = {
17
+ :'Content-Type' => 'application/json', :Accept => 'application/json'
18
+ }.freeze
19
+
20
+ CMDS = %w(alert integration dashboard event link message metric
21
+ proxy query savedsearch source user window webhook write).freeze
22
+
23
+ BAD_TAG="*BAD TAG*"
24
+ TW = 80
25
+
26
+ # Return an array of CLI permutations and the values to which they relate
27
+ #
28
+ def permutations
29
+ [ ["-t #{TOKEN} -E #{ENDPOINT}", { t: TOKEN, e: ENDPOINT }],
30
+ ["-c #{CF}", { t: CF_VAL['default']['token'],
31
+ e: CF_VAL['default']['endpoint'] }],
32
+ ["-c #{CF} -P other", { t: CF_VAL['other']['token'],
33
+ e: CF_VAL['other']['endpoint'] }],
34
+ ["-c #{CF} -P other -t #{TOKEN}", { t: TOKEN,
35
+ e: CF_VAL['other']['endpoint'] }],
36
+ ["-c #{CF} -E #{ENDPOINT}", { t: CF_VAL['default']['token'],
37
+ e: ENDPOINT }]
38
+ ]
39
+ end
40
+
41
+ # Match a command to the final API call it should produce, applying options in
42
+ # as many combinations as possible, and ensuring the requisite display methods
43
+ # are called.
44
+ #
45
+ # @param cmd [String] command line args to supply to the Wavefront
46
+ # command
47
+ # @param call [Hash]
48
+ #
49
+ def cmd_to_call(word, args, call, sdk_class = nil)
50
+ headers = { 'Accept': /.*/,
51
+ 'Accept-Encoding': /.*/,
52
+ 'Authorization': 'Bearer 0123456789-ABCDEF',
53
+ 'User-Agent': /wavefront-sdk .*/,
54
+ }
55
+
56
+ sdk_class ||= Object.const_get("WavefrontCli::#{word.capitalize}")
57
+
58
+ headers.merge!(call[:headers]) if call.key?(:headers)
59
+ method = call[:method] || :get
60
+ fmts = call[:formats] ? ['-f json', '-f yaml', '-f human', ''] : ['']
61
+
62
+ permutations.each do |opts, vals|
63
+ describe "with #{word} #{args}" do
64
+ fmts.each do |fmt|
65
+ cmd = "#{word} #{args} #{opts} #{fmt}"
66
+ uri = 'https://' + vals[:e] + call[:path]
67
+ h = headers.dup
68
+ h[:'Authorization'] = "Bearer #{vals[:t]}"
69
+
70
+ it "runs #{cmd} and makes the correct API call" do
71
+
72
+ if call.key?(:body)
73
+ stub_request(method, uri).with(headers: h, body: call[:body]).
74
+ to_return(body: {}.to_json, status: 200)
75
+ else
76
+ stub_request(method, uri).with(headers: h).
77
+ to_return(body: {}.to_json, status: 200)
78
+ end
79
+
80
+ require "wavefront-sdk/#{sdk_class.name.split('::').last.downcase}"
81
+ r = Spy.on_instance_method(Object.const_get(
82
+ "Wavefront::#{sdk_class.name.split('::').last}"),
83
+ :respond).and_return({})
84
+ d = Spy.on_instance_method(sdk_class, :display)
85
+ WavefrontCliController.new(cmd.split)
86
+ assert d.has_been_called?
87
+ assert_requested(method, uri, headers: h)
88
+ WebMock.reset!
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ # Run a command we expect to fail, returning stdout and stderr
96
+ #
97
+ def fail_command(cmd)
98
+ capture_io do
99
+ begin
100
+ WavefrontCliController.new(cmd.split).run
101
+ rescue SystemExit => e
102
+ assert_equal(1, e.status)
103
+ end
104
+ end
105
+ end
106
+
107
+ def invalid_something(cmd, subcmds, thing)
108
+ subcmds.each do |sc|
109
+ it "fails '#{sc}' because of an invalid #{thing}" do
110
+ out, err = fail_command("#{cmd} #{sc}")
111
+ assert_match(/^'.*' is not a valid #{thing}.\n$/, err)
112
+ end
113
+ end
114
+ end
115
+
116
+ def invalid_tags(cmd, subcmds)
117
+ subcmds.each do |sc|
118
+ it "fails '#{sc}' because of an invalid tag" do
119
+ out, err = fail_command("#{cmd} #{sc}")
120
+ assert out = "'#{BAD_TAG}' is not a valid tag.\n"
121
+ end
122
+ end
123
+ end
124
+
125
+ def invalid_ids(cmd, subcmds)
126
+ subcmds.each do |sc|
127
+ it "fails '#{sc}' on invalid input" do
128
+ out, err = fail_command("#{cmd} #{sc}")
129
+ assert_match(/^'.+' is not a valid \w/, err)
130
+ end
131
+ end
132
+ end
133
+
134
+ # Without a token, you should get an error. If you don't supply an endpoint, it
135
+ # will default to 'metrics.wavefront.com'.
136
+ #
137
+ def missing_creds(cmd, subcmds)
138
+ describe 'commands with missing credentials' do
139
+ subcmds.each do |subcmd|
140
+ it "'#{subcmd}' errors and tells the user to use a token" do
141
+ out, err = fail_command("#{cmd} #{subcmd} -c /f")
142
+ assert_match(/supply an API token/, err)
143
+ assert_match(/config file '\/f' not found./, out)
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ # Generic list tests, needed by most commands
150
+ #
151
+ def list_tests(cmd, pth = nil, k = nil)
152
+ pth = cmd unless pth
153
+ cmd_to_call(cmd, 'list', { path: "/api/v2/#{pth}?limit=100&offset=0" }, k)
154
+ cmd_to_call(cmd, 'list -L 50', { path: "/api/v2/#{pth}?limit=50&offset=0" },
155
+ k)
156
+ cmd_to_call(cmd, 'list -L 20 -o 8',
157
+ { path: "/api/v2/#{pth}?limit=20&offset=8" }, k)
158
+ cmd_to_call(cmd, 'list -o 60', { path: "/api/v2/#{pth}?limit=100&offset=60" },
159
+ k)
160
+ end
161
+
162
+ def tag_tests(cmd, id, bad_id, pth = nil)
163
+ pth ||= cmd
164
+ cmd_to_call(cmd, "tags #{id}", { path: "/api/v2/#{pth}/#{id}/tag" })
165
+ cmd_to_call(cmd, "tag set #{id} mytag",
166
+ { method: :post,
167
+ path: "/api/v2/#{pth}/#{id}/tag",
168
+ body: %w(mytag).to_json,
169
+ headers: JSON_POST_HEADERS })
170
+ cmd_to_call(cmd, "tag set #{id} mytag1 mytag2",
171
+ { method: :post,
172
+ path: "/api/v2/#{pth}/#{id}/tag",
173
+ body: %w(mytag1 mytag2).to_json,
174
+ headers: JSON_POST_HEADERS })
175
+ cmd_to_call(cmd, "tag add #{id} mytag",
176
+ { method: :put, path: "/api/v2/#{pth}/#{id}/tag/mytag" })
177
+ cmd_to_call(cmd, "tag delete #{id} mytag",
178
+ { method: :delete, path: "/api/v2/#{pth}/#{id}/tag/mytag" })
179
+ cmd_to_call(cmd, "tag clear #{id}", { method: :post,
180
+ path: "/api/v2/#{pth}/#{id}/tag",
181
+ body: [].to_json,
182
+ headers: JSON_POST_HEADERS })
183
+ invalid_ids(cmd, ["tags #{bad_id}", "tag clear #{bad_id}",
184
+ "tag add #{bad_id} mytag", "tag delete #{bad_id} mytag"])
185
+ invalid_tags(cmd, ["tag add #{id} #{BAD_TAG}", "tags #{id} #{BAD_TAG}",
186
+ "tags #{id} tag1 #{BAD_TAG}",
187
+ "tag delete #{id} #{BAD_TAG}"])
188
+ end
189
+
190
+ class Hash
191
+
192
+ # A quick way to deep-copy a hash.
193
+ #
194
+ def dup
195
+ Marshal.load(Marshal.dump(self))
196
+ end
197
+ end
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ id = '1481553823153'
4
+ bad_id = '__bad_id__'
5
+ word = 'alert'
6
+
7
+ require_relative '../spec_helper'
8
+ require_relative "../../lib/wavefront-cli/#{word}"
9
+
10
+ describe "#{word} command" do
11
+ missing_creds(word, ['list', "describe #{id}", "snooze #{id}",
12
+ "delete #{id}", "undelete #{id}", "history #{id}"])
13
+ list_tests(word)
14
+ cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
15
+ cmd_to_call(word, "describe -v 7 #{id}",
16
+ path: "/api/v2/#{word}/#{id}/history/7")
17
+ cmd_to_call(word, "history #{id}", path: "/api/v2/#{word}/#{id}/history")
18
+
19
+ it 'deletes with a check on inTrash' do
20
+ stub_request(:get,
21
+ 'https://other.wavefront.com/api/v2/alert/1481553823153').
22
+ with(headers: {'Accept': '*/*',
23
+ 'Accept-Encoding': 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
24
+ 'Authorization': 'Bearer 0123456789-ABCDEF',
25
+ 'User-Agent': /wavefront.*/}).
26
+ to_return(:status => 200, :body => "", :headers => {})
27
+ cmd_to_call(word, "delete #{id}",
28
+ method: :delete, path: "/api/v2/#{word}/#{id}")
29
+ end
30
+ cmd_to_call(word, "undelete #{id}",
31
+ method: :post, path: "/api/v2/#{word}/#{id}/undelete")
32
+ cmd_to_call(word, "snooze #{id}",
33
+ method: :post, path: "/api/v2/#{word}/#{id}/snooze")
34
+ cmd_to_call(word, "snooze -T 800 #{id}",
35
+ method: :post,
36
+ path: "/api/v2/#{word}/#{id}/snooze?seconds=800")
37
+ cmd_to_call(word, "unsnooze #{id}",
38
+ method: :post, path: "/api/v2/#{word}/#{id}/unsnooze")
39
+ cmd_to_call(word, 'summary', path: "/api/v2/#{word}/summary")
40
+ invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
41
+ "undelete #{bad_id}", "snooze #{bad_id}",
42
+ "snooze -T 500 #{bad_id}"])
43
+ tag_tests(word, id, bad_id)
44
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+ require_relative '../../lib/wavefront-cli/base'
5
+ require 'spy'
6
+ require 'spy/integration'
7
+
8
+ OPTS = {
9
+ endpoint: 'test.wavefront.com',
10
+ token: '0123456789-ABCDEF',
11
+ debug: false,
12
+ noop: true
13
+ }.freeze
14
+
15
+ OPTS_CMD = {
16
+ endpoint: 'test.wavefront.com',
17
+ token: '0123456789-ABCDEF',
18
+ debug: false,
19
+ noop: true,
20
+ test: true,
21
+ cmd: true
22
+ }.freeze
23
+
24
+ DISP_DATA = {
25
+ a: 'string',
26
+ b: %w(list_1 list_2)
27
+ }.freeze
28
+
29
+ class WavefrontCliBaseTest < MiniTest::Test
30
+ attr_reader :wf, :wf_cmd
31
+
32
+ def setup
33
+ @wf = WavefrontCli::Base.new(OPTS)
34
+ @wf_cmd = WavefrontCli::Base.new(OPTS_CMD)
35
+ wf_cmd.define_singleton_method(:do_test_cmd) { true }
36
+ end
37
+
38
+ def test_mk_creds
39
+ assert_equal wf.mk_creds, endpoint: 'test.wavefront.com',
40
+ token: '0123456789-ABCDEF'
41
+ end
42
+
43
+ def test_dispatch
44
+ assert_raises(WavefrontCli::Exception::UnhandledCommand) { wf.dispatch }
45
+ #assert_equal(wf_cmd.dispatch, nil)
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../lib/wavefront-cli/controller'
4
+ require_relative '../spec_helper'
5
+
6
+ # Be sure the CLI behaves properly when people ask for help
7
+ #
8
+ class WavefrontCliHelpTest < MiniTest::Test
9
+ def test_no_args
10
+ WavefrontCliController.new([])
11
+ rescue SystemExit => e
12
+ assert_equal(1, e.status)
13
+ assert_match(/^Usage/, e.message)
14
+ assert_match(/^ wavefront --version$/, e.message)
15
+ assert_match(/^ wavefront --help$/, e.message)
16
+ end
17
+
18
+ def test_version
19
+ WavefrontCliController.new(%w(--version))
20
+ rescue SystemExit => e
21
+ assert_equal(1, e.status)
22
+ assert_match(/^\d+\.\d+\.\d+$/, e.message)
23
+ end
24
+
25
+ def test_help
26
+ WavefrontCliController.new(%w(--help))
27
+ rescue SystemExit => e
28
+ assert_equal(1, e.status)
29
+ assert_match(/^Commands:$/, e.message)
30
+ CMDS.each do |cmd|
31
+ assert_match(/^ #{cmd} /, e.message)
32
+ end
33
+ end
34
+
35
+ def test_command_help
36
+ CMDS.each do |cmd|
37
+ begin
38
+ WavefrontCliController.new([cmd, '--help'])
39
+ rescue SystemExit => e
40
+ assert_equal(1, e.status)
41
+ assert_match(/^Usage:/, e.message)
42
+ assert_match(/^ #{CMD} #{cmd} /, e.message)
43
+ assert_match(/^ #{CMD} #{cmd} --help$/, e.message)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+ require_relative '../../lib/wavefront-cli/cloudintegration'
5
+
6
+ id = '3b56f61d-1a79-46f6-905c-d75a0f613d10'
7
+ bad_id = '__BAD__'
8
+ k = WavefrontCli::CloudIntegration
9
+ word = 'integration'
10
+
11
+ describe 'integration command' do
12
+ missing_creds(word, ['list', "describe #{id}", "delete #{id}",
13
+ "undelete #{id}"])
14
+ list_tests(word, 'cloudintegration', k)
15
+ cmd_to_call(word, "describe #{id}",
16
+ { path: "/api/v2/cloudintegration/#{id}" }, k)
17
+ cmd_to_call(word, "delete #{id}",
18
+ { method: :delete, path: "/api/v2/cloudintegration/#{id}" }, k)
19
+ cmd_to_call(word, "undelete #{id}",
20
+ { method: :post,
21
+ path: "/api/v2/cloudintegration/#{id}/undelete" }, k)
22
+ invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
23
+ "undelete #{bad_id}"])
24
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ id = 'test_dashboard'
4
+ bad_id = '>_<'
5
+ word = 'dashboard'
6
+
7
+ require_relative '../spec_helper'
8
+ require_relative "../../lib/wavefront-cli/#{word}"
9
+
10
+ describe "#{word} command" do
11
+ missing_creds(word, ['list', "describe #{id}", "delete #{id}",
12
+ "undelete #{id}", "history #{id}"])
13
+ list_tests(word)
14
+ cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
15
+ cmd_to_call(word, "describe -v 7 #{id}",
16
+ path: "/api/v2/#{word}/#{id}/history/7")
17
+ cmd_to_call(word, "history #{id}", path: "/api/v2/#{word}/#{id}/history")
18
+
19
+ it 'deletes with a check on inTrash' do
20
+ stub_request(:get,
21
+ "https://other.wavefront.com/api/v2/#{word}/#{id}").
22
+ with(headers: {'Accept': '*/*',
23
+ 'Accept-Encoding':
24
+ 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
25
+ 'Authorization': 'Bearer 0123456789-ABCDEF',
26
+ 'User-Agent': /wavefront.*/}).
27
+ to_return(:status => 200, :body => "", :headers => {})
28
+ cmd_to_call(word, "delete #{id}",
29
+ method: :delete, path: "/api/v2/#{word}/#{id}")
30
+ end
31
+
32
+ cmd_to_call(word, "undelete #{id}",
33
+ method: :post, path: "/api/v2/#{word}/#{id}/undelete")
34
+ invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}",
35
+ "undelete #{bad_id}"])
36
+ tag_tests(word, id, bad_id)
37
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ id = '1481553823153:testev'
4
+ bad_id = '__bad_id__'
5
+ word = 'event'
6
+
7
+ require_relative '../spec_helper'
8
+ require_relative "../../lib/wavefront-cli/#{word}"
9
+
10
+ describe "#{word} command" do
11
+ missing_creds(word, ['list', "describe #{id}", "create #{id}",
12
+ "close #{id}", "delete #{id}"])
13
+ cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
14
+ cmd_to_call(word, "create -N #{id}",
15
+ method: :post, path: "/api/v2/#{word}")
16
+ cmd_to_call(word, "close #{id}",
17
+ method: :post, path: "/api/v2/#{word}/#{id}/close")
18
+ tag_tests(word, id, bad_id)
19
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+ require_relative '../../lib/wavefront-cli/externallink'
5
+
6
+ id = 'lq6rPlSg2CFMSrg6'
7
+ bad_id = '__BAD__'
8
+ k = WavefrontCli::ExternalLink
9
+ word = 'link'
10
+
11
+ describe "#{word} command" do
12
+ missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
13
+ list_tests(word, 'extlink', k)
14
+ cmd_to_call(word, "describe #{id}", { path: "/api/v2/extlink/#{id}" }, k)
15
+ cmd_to_call(word, "delete #{id}",
16
+ { method: :delete, path: "/api/v2/extlink/#{id}" }, k)
17
+ invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}"])
18
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../spec_helper'
4
+ require_relative '../../lib/wavefront-cli/maintenancewindow'
5
+
6
+ id = '1493324005091'
7
+ bad_id = '__BAD__'
8
+ k = WavefrontCli::MaintenanceWindow
9
+ word = 'window'
10
+
11
+ describe "#{word} command" do
12
+ missing_creds(word, ['list', "describe #{id}", "delete #{id}"])
13
+ list_tests(word, 'maintenancewindow', k)
14
+ cmd_to_call(word, "describe #{id}",
15
+ { path: "/api/v2/maintenancewindow/#{id}" }, k)
16
+ cmd_to_call(word, "delete #{id}",
17
+ { method: :delete, path: "/api/v2/maintenancewindow/#{id}" }, k)
18
+ invalid_ids(word, ["describe #{bad_id}", "delete #{bad_id}"])
19
+ end