wavefront-cli 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +1147 -0
  4. data/README.md +1 -1
  5. data/lib/wavefront-cli/alert.rb +2 -3
  6. data/lib/wavefront-cli/base.rb +27 -20
  7. data/lib/wavefront-cli/commands/alert.rb +0 -1
  8. data/lib/wavefront-cli/commands/event.rb +3 -2
  9. data/lib/wavefront-cli/commands/query.rb +0 -1
  10. data/lib/wavefront-cli/commands/window.rb +0 -1
  11. data/lib/wavefront-cli/commands/write.rb +0 -1
  12. data/lib/wavefront-cli/constants.rb +0 -1
  13. data/lib/wavefront-cli/controller.rb +5 -5
  14. data/lib/wavefront-cli/display/alert.rb +3 -5
  15. data/lib/wavefront-cli/display/dashboard.rb +3 -3
  16. data/lib/wavefront-cli/display/webhook.rb +2 -2
  17. data/lib/wavefront-cli/display/write.rb +1 -1
  18. data/lib/wavefront-cli/event.rb +67 -53
  19. data/lib/wavefront-cli/integration.rb +0 -1
  20. data/lib/wavefront-cli/maintenancewindow.rb +36 -20
  21. data/lib/wavefront-cli/opt_handler.rb +1 -1
  22. data/lib/wavefront-cli/query.rb +44 -27
  23. data/lib/wavefront-cli/string.rb +13 -25
  24. data/lib/wavefront-cli/version.rb +1 -1
  25. data/lib/wavefront-cli/write.rb +2 -7
  26. data/spec/.rubocop.yml +16 -0
  27. data/spec/spec_helper.rb +55 -55
  28. data/spec/wavefront-cli/alert_spec.rb +8 -8
  29. data/spec/wavefront-cli/base_spec.rb +1 -1
  30. data/spec/wavefront-cli/cloudintegration_spec.rb +6 -6
  31. data/spec/wavefront-cli/commands/base_spec.rb +0 -2
  32. data/spec/wavefront-cli/controller_spec.rb +5 -5
  33. data/spec/wavefront-cli/dashboard_spec.rb +8 -8
  34. data/spec/wavefront-cli/display/base_spec.rb +22 -23
  35. data/spec/wavefront-cli/display/printer/long_spec.rb +30 -28
  36. data/spec/wavefront-cli/event_spec.rb +8 -8
  37. data/spec/wavefront-cli/externallink_spec.rb +6 -6
  38. data/spec/wavefront-cli/maintanancewindow_spec.rb +8 -9
  39. data/spec/wavefront-cli/opt_handler_spec.rb +4 -5
  40. data/spec/wavefront-cli/proxy_spec.rb +8 -8
  41. data/spec/wavefront-cli/savedsearch_spec.rb +6 -6
  42. data/spec/wavefront-cli/source_spec.rb +8 -8
  43. data/spec/wavefront-cli/string_spec.rb +2 -3
  44. data/spec/wavefront-cli/webhook_spec.rb +8 -8
  45. data/wavefront-cli.gemspec +3 -3
  46. metadata +20 -5
@@ -9,37 +9,54 @@ module WavefrontCli
9
9
  include Wavefront::Mixins
10
10
 
11
11
  def do_default
12
- opts = {
13
- autoEvents: options[:events],
14
- i: options[:inclusive],
15
- summarization: options[:summarize] || 'mean',
16
- listMode: true,
17
- strict: true,
18
- includeObsoleteMetrics: options[:obsolete],
19
- sorted: true
20
- }
12
+ t_start = window_start
13
+ t_end = window_end
14
+ granularity = granularity(t_start, t_end)
15
+ t_end = nil unless options[:end]
21
16
 
22
- options[:start] = if options[:start]
23
- parse_time(options[:start], true)
24
- else
25
- (Time.now - 600).to_i
26
- end
17
+ wf.query(options[:'<query>'], granularity, t_start, t_end, q_opts)
18
+ end
27
19
 
28
- if options[:end]
29
- options[:end] = parse_time(options[:end], true)
30
- t_end = options[:end]
20
+ # @return [Hash] options for the SDK query method
21
+ #
22
+ def q_opts
23
+ ret = { autoEvents: options[:events],
24
+ i: options[:inclusive],
25
+ summarization: options[:summarize] || 'mean',
26
+ listMode: true,
27
+ strict: true,
28
+ includeObsoleteMetrics: options[:obsolete],
29
+ sorted: true }
30
+
31
+ ret[:n] = options[:name] if options[:name]
32
+ ret[:p] = options[:points] if options[:points]
33
+ ret
34
+ end
35
+
36
+ # @return [Integer] start of query window. If one has been
37
+ # given, that; if not, ten minutes ago
38
+ #
39
+ def window_start
40
+ if options[:start]
41
+ parse_time(options[:start], true)
31
42
  else
32
- t_end = Time.now.to_i
43
+ (Time.now - 600).to_i
33
44
  end
45
+ end
34
46
 
35
- options[:granularity] ||= default_granularity((t_end -
36
- options[:start]).to_i)
37
-
38
- opts[:n] = options[:name] if options[:name]
39
- opts[:p] = options[:points] if options[:points]
47
+ # @return [Integer] end of query window. If one has been
48
+ # given, that; if not, now
49
+ #
50
+ def window_end
51
+ if options[:end]
52
+ parse_time(options[:end], true)
53
+ else
54
+ Time.now.to_i
55
+ end
56
+ end
40
57
 
41
- wf.query(options[:'<query>'], options[:granularity],
42
- options[:start], options[:end] || nil, opts)
58
+ def granularity(t_start, t_end)
59
+ options[:granularity] || default_granularity(t_start - t_end)
43
60
  end
44
61
 
45
62
  # Work out a sensible granularity based on the time window
@@ -47,9 +64,9 @@ module WavefrontCli
47
64
  def default_granularity(window)
48
65
  if window < 300
49
66
  :s
50
- elsif window < 10800
67
+ elsif window < 10_800
51
68
  :m
52
- elsif window < 259200
69
+ elsif window < 259_200
53
70
  :h
54
71
  else
55
72
  :d
@@ -8,9 +8,8 @@ class String
8
8
  # @param indent [Integer] size of hanging indent, in chars
9
9
  #
10
10
  def cmd_fold(tw = TW, indent = 10)
11
- #gsub(/\s(?=\w+\])/, '^').scan_line(tw - 8).join("\n" + ' ' * indent)
12
- gsub(/(-\w) /, "\\1^").scan_line(tw - 12).join("\n" + ' ' * indent)
13
- .tr('^', ' ')
11
+ gsub(/(-\w) /, '\\1^').scan_line(tw - 12).join("\n" + ' ' * indent)
12
+ .tr('^', ' ')
14
13
  end
15
14
 
16
15
  # Wrapper around #fold()
@@ -27,7 +26,6 @@ class String
27
26
  # for option folding, now addded the prefix parameter to make it
28
27
  # more general.
29
28
  #
30
- # rubocop:disable Metrics/AbcSize
31
29
  #
32
30
  # @param tw [Integer] terminal width
33
31
  # @param indent [Integer] size of hanging indent, in chars
@@ -35,17 +33,17 @@ class String
35
33
  # @return [String] the folded line
36
34
  #
37
35
  def fold(tw = TW, indent = 10, prefix = '')
38
- chunks = self.scan_line(tw - 8)
36
+ chunks = scan_line(tw - 8)
39
37
 
40
- line_1 = format("%s%s\n", prefix, chunks.shift)
38
+ first_line = format("%s%s\n", prefix, chunks.shift)
41
39
 
42
- return line_1 if chunks.empty?
40
+ return first_line if chunks.empty?
43
41
 
44
42
  rest = chunks.join(' ').scan_line(tw - indent - 5).map do |l|
45
43
  prefix + ' ' * indent + l
46
44
  end
47
45
 
48
- line_1 + rest.join("\n") + "\n"
46
+ first_line + rest.join("\n") + "\n"
49
47
  end
50
48
 
51
49
  # @param width [Integer] length of longest string (width of
@@ -59,26 +57,16 @@ class String
59
57
 
60
58
  def to_seconds
61
59
  begin
62
- number, unit = self.match(/^(\d+)([smhdw])$/).captures
63
- rescue
60
+ number, unit = match(/^(\d+)([smhdw])$/).captures
61
+ rescue NoMethodError
64
62
  raise ArgumentError
65
63
  end
66
64
 
67
- factor = case unit
68
- when 's'
69
- 1
70
- when 'm'
71
- 60
72
- when 'h'
73
- 3600
74
- when 'd'
75
- 86400
76
- when 'w'
77
- 604800
78
- else
79
- raise ArgumentError
80
- end
65
+ number.to_i * unit_factor(unit.to_sym)
66
+ end
81
67
 
82
- number.to_i * factor
68
+ def unit_factor(unit)
69
+ factors = { s: 1, m: 60, h: 3600, d: 86_400, w: 604_800 }
70
+ factors[unit] || 1
83
71
  end
84
72
  end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.1.4'.freeze
1
+ WF_CLI_VERSION = '2.1.5'.freeze
@@ -5,7 +5,6 @@ module WavefrontCli
5
5
  #
6
6
  # Send points to a proxy.
7
7
  #
8
- # rubocop:disable Metrics/ClassLength
9
8
  class Write < Base
10
9
  attr_reader :fmt
11
10
  include Wavefront::Mixins
@@ -13,9 +12,6 @@ module WavefrontCli
13
12
  def mk_creds
14
13
  { proxy: options[:proxy], port: options[:port] || 2878 }
15
14
  end
16
-
17
- # rubocop:disable Metrics/AbcSize
18
- # rubocop:disable Metrics/MethodLength
19
15
  def do_point
20
16
  p = { path: options[:'<metric>'],
21
17
  value: options[:'<value>'].to_f,
@@ -221,7 +217,7 @@ module WavefrontCli
221
217
  #
222
218
  def valid_timestamp?(ts)
223
219
  (ts.is_a?(Integer) || ts.match(/^\d+$/)) &&
224
- ts.to_i > 946684800 && ts.to_i < (Time.now.to_i + 31557600)
220
+ ts.to_i > 946_684_800 && ts.to_i < (Time.now.to_i + 31_557_600)
225
221
  end
226
222
 
227
223
  def validate_opts
@@ -239,9 +235,8 @@ module WavefrontCli
239
235
  end
240
236
 
241
237
  def load_data(file)
242
- IO.read(file)
243
- rescue
244
238
  raise "Cannot open file '#{file}'." unless file.exist?
239
+ IO.read(file)
245
240
  end
246
241
  end
247
242
  end
data/spec/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ # Allow long blocks of tests
5
+ #
6
+ Metrics/BlockLength:
7
+ Max: 120
8
+
9
+ Metrics/MethodLength:
10
+ Max: 80
11
+
12
+ Metrics/AbcSize:
13
+ Max: 45
14
+
15
+ Metrics/ClassLength:
16
+ Max: 300
data/spec/spec_helper.rb CHANGED
@@ -9,35 +9,34 @@ require_relative '../lib/wavefront-cli/controller'
9
9
 
10
10
  unless defined?(CMD)
11
11
  CMD = 'wavefront'.freeze
12
- ENDPOINT = 'metrics.wavefront.com'
13
- TOKEN = '0123456789-ABCDEF'
12
+ ENDPOINT = 'metrics.wavefront.com'.freeze
13
+ TOKEN = '0123456789-ABCDEF'.freeze
14
14
  RES_DIR = Pathname.new(__FILE__).dirname + 'wavefront-cli' + 'resources'
15
15
  CF = RES_DIR + 'wavefront.conf'
16
16
  CF_VAL = IniFile.load(CF)
17
17
  JSON_POST_HEADERS = {
18
- :'Content-Type' => 'application/json', :Accept => 'application/json'
18
+ 'Content-Type': 'application/json', Accept: 'application/json'
19
19
  }.freeze
20
20
 
21
- CMDS = %w(alert integration dashboard event link message metric
22
- proxy query savedsearch source user window webhook write).freeze
21
+ CMDS = %w[alert integration dashboard event link message metric
22
+ proxy query savedsearch source user window webhook write].freeze
23
23
 
24
- BAD_TAG="*BAD TAG*"
24
+ BAD_TAG = '*BAD_TAG*'.freeze
25
25
  TW = 80
26
26
  end
27
27
 
28
28
  # Return an array of CLI permutations and the values to which they relate
29
29
  #
30
30
  def permutations
31
- [ ["-t #{TOKEN} -E #{ENDPOINT}", { t: TOKEN, e: ENDPOINT }],
32
- ["-c #{CF}", { t: CF_VAL['default']['token'],
33
- e: CF_VAL['default']['endpoint'] }],
34
- ["-c #{CF} -P other", { t: CF_VAL['other']['token'],
35
- e: CF_VAL['other']['endpoint'] }],
36
- ["-c #{CF} -P other -t #{TOKEN}", { t: TOKEN,
37
- e: CF_VAL['other']['endpoint'] }],
38
- ["-c #{CF} -E #{ENDPOINT}", { t: CF_VAL['default']['token'],
39
- e: ENDPOINT }]
40
- ]
31
+ [["-t #{TOKEN} -E #{ENDPOINT}", { t: TOKEN, e: ENDPOINT }],
32
+ ["-c #{CF}", { t: CF_VAL['default']['token'],
33
+ e: CF_VAL['default']['endpoint'] }],
34
+ ["-c #{CF} -P other", { t: CF_VAL['other']['token'],
35
+ e: CF_VAL['other']['endpoint'] }],
36
+ ["-c #{CF} -P other -t #{TOKEN}", { t: TOKEN,
37
+ e: CF_VAL['other']['endpoint'] }],
38
+ ["-c #{CF} -E #{ENDPOINT}", { t: CF_VAL['default']['token'],
39
+ e: ENDPOINT }]]
41
40
  end
42
41
 
43
42
  # Match a command to the final API call it should produce, applying options in
@@ -48,12 +47,12 @@ end
48
47
  # command
49
48
  # @param call [Hash]
50
49
  #
50
+ # rubocop:disable Metrics/AbcSize
51
51
  def cmd_to_call(word, args, call, sdk_class = nil)
52
52
  headers = { 'Accept': /.*/,
53
53
  'Accept-Encoding': /.*/,
54
54
  'Authorization': 'Bearer 0123456789-ABCDEF',
55
- 'User-Agent': "wavefront-cli-#{WF_CLI_VERSION}"
56
- }
55
+ 'User-Agent': "wavefront-cli-#{WF_CLI_VERSION}" }
57
56
 
58
57
  sdk_class ||= Object.const_get("WavefrontCli::#{word.capitalize}")
59
58
 
@@ -67,23 +66,25 @@ def cmd_to_call(word, args, call, sdk_class = nil)
67
66
  cmd = "#{word} #{args} #{opts} #{fmt}"
68
67
  uri = 'https://' + vals[:e] + call[:path]
69
68
  h = headers.dup
70
- h[:'Authorization'] = "Bearer #{vals[:t]}"
69
+ h[:Authorization] = "Bearer #{vals[:t]}"
71
70
 
72
71
  it "runs #{cmd} and makes the correct API call" do
73
-
74
72
  if call.key?(:body)
75
- stub_request(method, uri).with(headers: h, body: call[:body]).
76
- to_return(body: {}.to_json, status: 200)
73
+ stub_request(method, uri).with(headers: h, body: call[:body])
74
+ .to_return(body: {}.to_json, status: 200)
77
75
  else
78
- stub_request(method, uri).with(headers: h).
79
- to_return(body: {}.to_json, status: 200)
76
+ stub_request(method, uri).with(headers: h)
77
+ .to_return(body: {}.to_json, status: 200)
80
78
  end
81
79
 
82
80
  require "wavefront-sdk/#{sdk_class.name.split('::').last.downcase}"
83
- r = Spy.on_instance_method(Object.const_get(
84
- "Wavefront::#{sdk_class.name.split('::').last}"),
85
- :respond).and_return({})
86
- d = Spy.on_instance_method(sdk_class, :display)
81
+ Spy.on_instance_method(
82
+ Object.const_get(
83
+ "Wavefront::#{sdk_class.name.split('::').last}"
84
+ ),
85
+ :respond
86
+ ).and_return({})
87
+ d = Spy.on_instance_method(sdk_class, :display)
87
88
  WavefrontCliController.new(cmd.split)
88
89
  assert d.has_been_called?
89
90
  assert_requested(method, uri, headers: h)
@@ -109,8 +110,8 @@ end
109
110
  def invalid_something(cmd, subcmds, thing)
110
111
  subcmds.each do |sc|
111
112
  it "fails '#{sc}' because of an invalid #{thing}" do
112
- out, err = fail_command("#{cmd} #{sc}")
113
- assert_match(/^'.*' is not a valid #{thing}.\n$/, err)
113
+ _out, err = fail_command("#{cmd} #{sc}")
114
+ assert_match(/^'.*' is not a valid #{thing}.\n$/, err)
114
115
  end
115
116
  end
116
117
  end
@@ -118,8 +119,8 @@ end
118
119
  def invalid_tags(cmd, subcmds)
119
120
  subcmds.each do |sc|
120
121
  it "fails '#{sc}' because of an invalid tag" do
121
- out, err = fail_command("#{cmd} #{sc}")
122
- assert out = "'#{BAD_TAG}' is not a valid tag.\n"
122
+ _out, err = fail_command("#{cmd} #{sc}")
123
+ assert_equal(err, "'#{BAD_TAG}' is not a valid tag.\n")
123
124
  end
124
125
  end
125
126
  end
@@ -127,8 +128,8 @@ end
127
128
  def invalid_ids(cmd, subcmds)
128
129
  subcmds.each do |sc|
129
130
  it "fails '#{sc}' on invalid input" do
130
- out, err = fail_command("#{cmd} #{sc}")
131
- assert_match(/^'.+' is not a valid \w/, err)
131
+ _out, err = fail_command("#{cmd} #{sc}")
132
+ assert_match(/^'.+' is not a valid \w/, err)
132
133
  end
133
134
  end
134
135
  end
@@ -142,7 +143,7 @@ def missing_creds(cmd, subcmds)
142
143
  it "'#{subcmd}' errors and tells the user to use a token" do
143
144
  out, err = fail_command("#{cmd} #{subcmd} -c /f")
144
145
  assert_match(/supply an API token/, err)
145
- assert_match(/config file '\/f' not found./, out)
146
+ assert_match(%r{config file '/f' not found.}, out)
146
147
  end
147
148
  end
148
149
  end
@@ -151,7 +152,7 @@ end
151
152
  # Generic list tests, needed by most commands
152
153
  #
153
154
  def list_tests(cmd, pth = nil, k = nil)
154
- pth = cmd unless pth
155
+ pth ||= cmd
155
156
  cmd_to_call(cmd, 'list', { path: "/api/v2/#{pth}?limit=100&offset=0" }, k)
156
157
  cmd_to_call(cmd, 'list -L 50', { path: "/api/v2/#{pth}?limit=50&offset=0" },
157
158
  k)
@@ -163,34 +164,33 @@ end
163
164
 
164
165
  def tag_tests(cmd, id, bad_id, pth = nil)
165
166
  pth ||= cmd
166
- cmd_to_call(cmd, "tags #{id}", { path: "/api/v2/#{pth}/#{id}/tag" })
167
+ cmd_to_call(cmd, "tags #{id}", path: "/api/v2/#{pth}/#{id}/tag")
167
168
  cmd_to_call(cmd, "tag set #{id} mytag",
168
- { method: :post,
169
- path: "/api/v2/#{pth}/#{id}/tag",
170
- body: %w(mytag).to_json,
171
- headers: JSON_POST_HEADERS })
169
+ method: :post,
170
+ path: "/api/v2/#{pth}/#{id}/tag",
171
+ body: %w[mytag].to_json,
172
+ headers: JSON_POST_HEADERS)
172
173
  cmd_to_call(cmd, "tag set #{id} mytag1 mytag2",
173
- { method: :post,
174
- path: "/api/v2/#{pth}/#{id}/tag",
175
- body: %w(mytag1 mytag2).to_json,
176
- headers: JSON_POST_HEADERS })
174
+ method: :post,
175
+ path: "/api/v2/#{pth}/#{id}/tag",
176
+ body: %w[mytag1 mytag2].to_json,
177
+ headers: JSON_POST_HEADERS)
177
178
  cmd_to_call(cmd, "tag add #{id} mytag",
178
- { method: :put, path: "/api/v2/#{pth}/#{id}/tag/mytag" })
179
+ method: :put, path: "/api/v2/#{pth}/#{id}/tag/mytag")
179
180
  cmd_to_call(cmd, "tag delete #{id} mytag",
180
- { method: :delete, path: "/api/v2/#{pth}/#{id}/tag/mytag" })
181
- cmd_to_call(cmd, "tag clear #{id}", { method: :post,
182
- path: "/api/v2/#{pth}/#{id}/tag",
183
- body: [].to_json,
184
- headers: JSON_POST_HEADERS })
181
+ method: :delete, path: "/api/v2/#{pth}/#{id}/tag/mytag")
182
+ cmd_to_call(cmd, "tag clear #{id}", method: :post,
183
+ path: "/api/v2/#{pth}/#{id}/tag",
184
+ body: [].to_json,
185
+ headers: JSON_POST_HEADERS)
185
186
  invalid_ids(cmd, ["tags #{bad_id}", "tag clear #{bad_id}",
186
187
  "tag add #{bad_id} mytag", "tag delete #{bad_id} mytag"])
187
- invalid_tags(cmd, ["tag add #{id} #{BAD_TAG}", "tags #{id} #{BAD_TAG}",
188
- "tags #{id} tag1 #{BAD_TAG}",
189
- "tag delete #{id} #{BAD_TAG}"])
188
+ invalid_tags(cmd, ["tag add #{id} #{BAD_TAG}", "tag delete #{id} #{BAD_TAG}"])
190
189
  end
191
190
 
191
+ # stdlib extensions
192
+ #
192
193
  class Hash
193
-
194
194
  # A quick way to deep-copy a hash.
195
195
  #
196
196
  def dup
@@ -34,14 +34,14 @@ describe "#{word} command" do
34
34
  cmd_to_call(word, "snooze #{id}",
35
35
  method: :post, path: "/api/v2/#{word}/#{id}/snooze")
36
36
  cmd_to_call(word, "search id=#{id}",
37
- { method: :post, path: "/api/v2/search/#{word}",
38
- body: { limit: 10,
39
- offset: 0,
40
- query: [{key: 'id',
41
- value: id,
42
- matchingMethod: 'EXACT'}],
43
- sort: {field: 'id', ascending: true}},
44
- headers: JSON_POST_HEADERS })
37
+ method: :post, path: "/api/v2/search/#{word}",
38
+ body: { limit: 10,
39
+ offset: 0,
40
+ query: [{ key: 'id',
41
+ value: id,
42
+ matchingMethod: 'EXACT' }],
43
+ sort: { field: 'id', ascending: true } },
44
+ headers: JSON_POST_HEADERS)
45
45
  cmd_to_call(word, "snooze -T 800 #{id}",
46
46
  method: :post,
47
47
  path: "/api/v2/#{word}/#{id}/snooze?seconds=800")
@@ -23,7 +23,7 @@ OPTS_CMD = {
23
23
 
24
24
  DISP_DATA = {
25
25
  a: 'string',
26
- b: %w(list_1 list_2)
26
+ b: %w[list_1 list_2]
27
27
  }.freeze
28
28
 
29
29
  # Test base class
@@ -17,13 +17,13 @@ describe 'cloudintegration command' do
17
17
  cmd_to_call(word, "delete #{id}",
18
18
  { method: :delete, path: "/api/v2/cloudintegration/#{id}" }, k)
19
19
  cmd_to_call(word, "search -L 100 id~#{id}",
20
- { method: :post, path: "/api/v2/search/cloudintegration",
21
- body: { limit: "100",
20
+ { method: :post, path: '/api/v2/search/cloudintegration',
21
+ body: { limit: '100',
22
22
  offset: 0,
23
- query: [{key: 'id',
24
- value: id,
25
- matchingMethod: 'CONTAINS'}],
26
- sort: {field: 'id', ascending: true}},
23
+ query: [{ key: 'id',
24
+ value: id,
25
+ matchingMethod: 'CONTAINS' }],
26
+ sort: { field: 'id', ascending: true } },
27
27
  headers: JSON_POST_HEADERS }, WavefrontCli::CloudIntegration)
28
28
  cmd_to_call(word, "undelete #{id}",
29
29
  { method: :post,
@@ -64,7 +64,6 @@ class WavefrontCommmandBaseTest < MiniTest::Test
64
64
  assert_equal(wf.sdk_file, word.downcase)
65
65
  end
66
66
 
67
- # rubocop:disable Metrics/AbcSize
68
67
  def test_commands
69
68
  assert wf.commands.start_with?("Usage:\n")
70
69
  assert wf.commands.match(/ --help$/)
@@ -90,7 +89,6 @@ class WavefrontCommmandBaseTest < MiniTest::Test
90
89
  assert_equal(wf.options.split("\n").select(&:empty?).size, 1)
91
90
  end
92
91
 
93
- # rubocop:disable Metrics/MethodLength
94
92
  def test_opt_row
95
93
  assert_equal(wf.opt_row('-s, --short short option', 10),
96
94
  " -s, --short short option\n")
@@ -16,22 +16,20 @@ class WavefrontCliHelpTest < MiniTest::Test
16
16
  end
17
17
 
18
18
  def test_version
19
- WavefrontCliController.new(%w(--version))
19
+ WavefrontCliController.new(%w[--version])
20
20
  rescue SystemExit => e
21
21
  assert_equal(1, e.status)
22
22
  assert_match(/^\d+\.\d+\.\d+$/, e.message)
23
23
  end
24
24
 
25
25
  def test_help
26
- WavefrontCliController.new(%w(--help))
26
+ WavefrontCliController.new(%w[--help])
27
27
  rescue SystemExit => e
28
28
  assert_equal(1, e.status)
29
29
  assert_match(/^Commands:$/, e.message)
30
30
  CMDS.each { |cmd| assert_match(/^ #{cmd} /, e.message) }
31
31
  end
32
32
 
33
- # rubocop:disable Metrics/AbcSize
34
- # rubocop:disable Metrics/MethodLength
35
33
  def test_command_help
36
34
  CMDS.each do |cmd|
37
35
  begin
@@ -56,6 +54,8 @@ class Giblets < WavefrontCliController
56
54
  def initialize; end
57
55
  end
58
56
 
57
+ # Here's the subclass
58
+ #
59
59
  class GibletsTest < MiniTest::Test
60
60
  attr_reader :wfc
61
61
 
@@ -66,6 +66,6 @@ class GibletsTest < MiniTest::Test
66
66
  def test_sanitize_keys
67
67
  h_in = { '--help': true, stuff: false, 'key' => 'value' }
68
68
  assert_equal(wfc.sanitize_keys(h_in),
69
- { help: true, stuff: false, key: 'value' })
69
+ help: true, stuff: false, key: 'value')
70
70
  end
71
71
  end
@@ -30,14 +30,14 @@ describe "#{word} command" do
30
30
  end
31
31
 
32
32
  cmd_to_call(word, "search id=#{id}",
33
- { method: :post, path: "/api/v2/search/#{word}",
34
- body: { limit: 10,
35
- offset: 0,
36
- query: [{key: 'id',
37
- value: id,
38
- matchingMethod: 'EXACT'}],
39
- sort: {field: 'id', ascending: true}},
40
- headers: JSON_POST_HEADERS })
33
+ method: :post, path: "/api/v2/search/#{word}",
34
+ body: { limit: 10,
35
+ offset: 0,
36
+ query: [{ key: 'id',
37
+ value: id,
38
+ matchingMethod: 'EXACT' }],
39
+ sort: { field: 'id', ascending: true } },
40
+ headers: JSON_POST_HEADERS)
41
41
 
42
42
  cmd_to_call(word, "undelete #{id}",
43
43
  method: :post, path: "/api/v2/#{word}/#{id}/undelete")