wavefront-cli 8.5.1 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +4 -4
  3. data/.github/workflows/test.yml +2 -2
  4. data/.rubocop.yml +1 -4
  5. data/HISTORY.md +12 -0
  6. data/README.md +4 -2
  7. data/lib/wavefront-cli/base.rb +2 -2
  8. data/lib/wavefront-cli/commands/base.rb +10 -9
  9. data/lib/wavefront-cli/commands/derivedmetric.rb +1 -1
  10. data/lib/wavefront-cli/commands/metric.rb +3 -3
  11. data/lib/wavefront-cli/commands/metricspolicy.rb +33 -0
  12. data/lib/wavefront-cli/commands/query.rb +5 -5
  13. data/lib/wavefront-cli/commands/write.rb +12 -12
  14. data/lib/wavefront-cli/config.rb +4 -4
  15. data/lib/wavefront-cli/constants.rb +2 -1
  16. data/lib/wavefront-cli/controller.rb +19 -15
  17. data/lib/wavefront-cli/display/metricspolicy.rb +15 -0
  18. data/lib/wavefront-cli/display/printer/long.rb +11 -13
  19. data/lib/wavefront-cli/display/printer/sparkline.rb +3 -3
  20. data/lib/wavefront-cli/display/query.rb +1 -1
  21. data/lib/wavefront-cli/display/write.rb +2 -1
  22. data/lib/wavefront-cli/event.rb +2 -2
  23. data/lib/wavefront-cli/exception_handler.rb +4 -1
  24. data/lib/wavefront-cli/helpers/load_file.rb +2 -2
  25. data/lib/wavefront-cli/maintenancewindow.rb +1 -1
  26. data/lib/wavefront-cli/metricspolicy.rb +42 -0
  27. data/lib/wavefront-cli/opt_handler.rb +2 -3
  28. data/lib/wavefront-cli/output/csv/query.rb +2 -2
  29. data/lib/wavefront-cli/output/hcl/dashboard.rb +6 -6
  30. data/lib/wavefront-cli/output/hcl/stdlib/array.rb +1 -1
  31. data/lib/wavefront-cli/output/wavefront/query.rb +7 -7
  32. data/lib/wavefront-cli/stdlib/string.rb +4 -4
  33. data/lib/wavefront-cli/usage.rb +1 -1
  34. data/lib/wavefront-cli/version.rb +1 -1
  35. data/lib/wavefront-cli/write.rb +13 -17
  36. data/spec/constants.rb +4 -5
  37. data/spec/support/command_base.rb +12 -0
  38. data/spec/support/minitest_assertions.rb +14 -10
  39. data/spec/support/output_tester.rb +2 -2
  40. data/spec/support/supported_commands.rb +3 -1
  41. data/spec/test_mixins/import.rb +2 -2
  42. data/spec/test_mixins/search.rb +9 -7
  43. data/spec/test_mixins/set.rb +1 -1
  44. data/spec/wavefront-cli/account_spec.rb +6 -4
  45. data/spec/wavefront-cli/alert_spec.rb +29 -6
  46. data/spec/wavefront-cli/commands/base_spec.rb +2 -2
  47. data/spec/wavefront-cli/commands/config_spec.rb +2 -2
  48. data/spec/wavefront-cli/config_spec.rb +3 -3
  49. data/spec/wavefront-cli/controller_spec.rb +2 -0
  50. data/spec/wavefront-cli/dashboard_spec.rb +1 -1
  51. data/spec/wavefront-cli/derivedmetric_spec.rb +9 -7
  52. data/spec/wavefront-cli/display/printer/long_spec.rb +5 -3
  53. data/spec/wavefront-cli/display/printer/terse_spec.rb +1 -1
  54. data/spec/wavefront-cli/event_spec.rb +14 -11
  55. data/spec/wavefront-cli/event_store_spec.rb +16 -12
  56. data/spec/wavefront-cli/externallink_spec.rb +5 -3
  57. data/spec/wavefront-cli/maintenancewindow_spec.rb +25 -19
  58. data/spec/wavefront-cli/message_spec.rb +3 -3
  59. data/spec/wavefront-cli/metricspolicy_spec.rb +30 -0
  60. data/spec/wavefront-cli/opt_handler_spec.rb +1 -1
  61. data/spec/wavefront-cli/output/helpers.rb +1 -1
  62. data/spec/wavefront-cli/proxy_spec.rb +1 -1
  63. data/spec/wavefront-cli/query_spec.rb +1 -1
  64. data/spec/wavefront-cli/role_spec.rb +4 -3
  65. data/spec/wavefront-cli/serviceaccount_spec.rb +7 -5
  66. data/spec/wavefront-cli/stdlib/string_spec.rb +3 -1
  67. data/spec/wavefront-cli/usage_spec.rb +1 -1
  68. data/spec/wavefront-cli/{write_spec.rb → write_class_spec.rb} +1 -14
  69. data/wavefront-cli.gemspec +13 -15
  70. metadata +32 -149
  71. data/spec/spec_helper.rb +0 -113
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.1
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2023-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: '0.6'
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.6.0
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: inifile
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,34 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.4'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 5.4.2
47
+ version: '7.0'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '5.4'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 5.4.2
54
+ version: '7.0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: minitest
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '5.14'
61
+ version: '5.17'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '5.14'
68
+ version: '5.17'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: rake
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -92,98 +86,98 @@ dependencies:
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '1.9'
89
+ version: '1.43'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: '1.9'
96
+ version: '1.43'
103
97
  - !ruby/object:Gem::Dependency
104
98
  name: rubocop-minitest
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
101
  - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: '0.10'
103
+ version: '0.26'
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: '0.10'
110
+ version: '0.26'
117
111
  - !ruby/object:Gem::Dependency
118
112
  name: rubocop-performance
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: '1.3'
117
+ version: '1.15'
124
118
  type: :development
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: '1.3'
124
+ version: '1.15'
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: rubocop-rake
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - "~>"
136
130
  - !ruby/object:Gem::Version
137
- version: '0.5'
131
+ version: '0.6'
138
132
  type: :development
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
136
  - - "~>"
143
137
  - !ruby/object:Gem::Version
144
- version: '0.5'
138
+ version: '0.6'
145
139
  - !ruby/object:Gem::Dependency
146
140
  name: spy
147
141
  requirement: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - "~>"
150
144
  - !ruby/object:Gem::Version
151
- version: 1.0.0
145
+ version: '1.0'
152
146
  type: :development
153
147
  prerelease: false
154
148
  version_requirements: !ruby/object:Gem::Requirement
155
149
  requirements:
156
150
  - - "~>"
157
151
  - !ruby/object:Gem::Version
158
- version: 1.0.0
152
+ version: '1.0'
159
153
  - !ruby/object:Gem::Dependency
160
154
  name: webmock
161
155
  requirement: !ruby/object:Gem::Requirement
162
156
  requirements:
163
157
  - - "~>"
164
158
  - !ruby/object:Gem::Version
165
- version: '3.8'
159
+ version: '3.18'
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - "~>"
171
165
  - !ruby/object:Gem::Version
172
- version: '3.8'
166
+ version: '3.18'
173
167
  - !ruby/object:Gem::Dependency
174
168
  name: yard
175
169
  requirement: !ruby/object:Gem::Requirement
176
170
  requirements:
177
171
  - - "~>"
178
172
  - !ruby/object:Gem::Version
179
- version: 0.9.5
173
+ version: '0.9'
180
174
  type: :development
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - "~>"
185
179
  - !ruby/object:Gem::Version
186
- version: 0.9.5
180
+ version: '0.9'
187
181
  description: 'CLI for Wavefront (wavefront.com) API v2 '
188
182
  email: services@id264.net
189
183
  executables:
@@ -224,6 +218,7 @@ files:
224
218
  - lib/wavefront-cli/commands/link.rb
225
219
  - lib/wavefront-cli/commands/message.rb
226
220
  - lib/wavefront-cli/commands/metric.rb
221
+ - lib/wavefront-cli/commands/metricspolicy.rb
227
222
  - lib/wavefront-cli/commands/notificant.rb
228
223
  - lib/wavefront-cli/commands/proxy.rb
229
224
  - lib/wavefront-cli/commands/query.rb
@@ -258,6 +253,7 @@ files:
258
253
  - lib/wavefront-cli/display/maintenancewindow.rb
259
254
  - lib/wavefront-cli/display/message.rb
260
255
  - lib/wavefront-cli/display/metric.rb
256
+ - lib/wavefront-cli/display/metricspolicy.rb
261
257
  - lib/wavefront-cli/display/notificant.rb
262
258
  - lib/wavefront-cli/display/printer/long.rb
263
259
  - lib/wavefront-cli/display/printer/sparkline.rb
@@ -285,6 +281,7 @@ files:
285
281
  - lib/wavefront-cli/maintenancewindow.rb
286
282
  - lib/wavefront-cli/message.rb
287
283
  - lib/wavefront-cli/metric.rb
284
+ - lib/wavefront-cli/metricspolicy.rb
288
285
  - lib/wavefront-cli/notificant.rb
289
286
  - lib/wavefront-cli/opt_handler.rb
290
287
  - lib/wavefront-cli/output/base.rb
@@ -321,7 +318,6 @@ files:
321
318
  - lib/wavefront-cli/write.rb
322
319
  - spec/.rubocop.yml
323
320
  - spec/constants.rb
324
- - spec/spec_helper.rb
325
321
  - spec/support/command_base.rb
326
322
  - spec/support/minitest_assertions.rb
327
323
  - spec/support/output_tester.rb
@@ -372,6 +368,7 @@ files:
372
368
  - spec/wavefront-cli/maintenancewindow_spec.rb
373
369
  - spec/wavefront-cli/message_spec.rb
374
370
  - spec/wavefront-cli/metric_spec.rb
371
+ - spec/wavefront-cli/metricspolicy_spec.rb
375
372
  - spec/wavefront-cli/notificant_spec.rb
376
373
  - spec/wavefront-cli/opt_handler_spec.rb
377
374
  - spec/wavefront-cli/output/csv/query_spec.rb
@@ -433,12 +430,13 @@ files:
433
430
  - spec/wavefront-cli/usage_spec.rb
434
431
  - spec/wavefront-cli/usergroup_spec.rb
435
432
  - spec/wavefront-cli/webhook_spec.rb
436
- - spec/wavefront-cli/write_spec.rb
433
+ - spec/wavefront-cli/write_class_spec.rb
437
434
  - wavefront-cli.gemspec
438
435
  homepage: https://github.com/snltd/wavefront-cli
439
436
  licenses:
440
437
  - BSD-2-Clause
441
- metadata: {}
438
+ metadata:
439
+ rubygems_mfa_required: 'true'
442
440
  post_install_message:
443
441
  rdoc_options: []
444
442
  require_paths:
@@ -447,130 +445,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
447
445
  requirements:
448
446
  - - ">="
449
447
  - !ruby/object:Gem::Version
450
- version: 2.5.0
448
+ version: 2.7.0
451
449
  required_rubygems_version: !ruby/object:Gem::Requirement
452
450
  requirements:
453
451
  - - ">="
454
452
  - !ruby/object:Gem::Version
455
453
  version: '0'
456
454
  requirements: []
457
- rubygems_version: 3.1.4
455
+ rubygems_version: 3.4.1
458
456
  signing_key:
459
457
  specification_version: 4
460
458
  summary: CLI for Wavefront API v2
461
- test_files:
462
- - spec/.rubocop.yml
463
- - spec/constants.rb
464
- - spec/spec_helper.rb
465
- - spec/support/command_base.rb
466
- - spec/support/minitest_assertions.rb
467
- - spec/support/output_tester.rb
468
- - spec/support/supported_commands.rb
469
- - spec/test_mixins/acl.rb
470
- - spec/test_mixins/delete.rb
471
- - spec/test_mixins/deleteundelete.rb
472
- - spec/test_mixins/describe.rb
473
- - spec/test_mixins/dump.rb
474
- - spec/test_mixins/general.rb
475
- - spec/test_mixins/history.rb
476
- - spec/test_mixins/import.rb
477
- - spec/test_mixins/list.rb
478
- - spec/test_mixins/search.rb
479
- - spec/test_mixins/set.rb
480
- - spec/test_mixins/tag.rb
481
- - spec/wavefront-cli/account_spec.rb
482
- - spec/wavefront-cli/alert_spec.rb
483
- - spec/wavefront-cli/apitoken_spec.rb
484
- - spec/wavefront-cli/base_spec.rb
485
- - spec/wavefront-cli/cloudintegration_spec.rb
486
- - spec/wavefront-cli/commands/alert_spec.rb
487
- - spec/wavefront-cli/commands/base_spec.rb
488
- - spec/wavefront-cli/commands/cloudintegration_spec.rb
489
- - spec/wavefront-cli/commands/config_spec.rb
490
- - spec/wavefront-cli/commands/dashboard_spec.rb
491
- - spec/wavefront-cli/commands/derivedmetric_spec.rb
492
- - spec/wavefront-cli/commands/event_spec.rb
493
- - spec/wavefront-cli/commands/link_spec.rb
494
- - spec/wavefront-cli/commands/message_spec.rb
495
- - spec/wavefront-cli/commands/metric_spec.rb
496
- - spec/wavefront-cli/commands/proxy_spec.rb
497
- - spec/wavefront-cli/commands/query_spec.rb
498
- - spec/wavefront-cli/commands/webhook_spec.rb
499
- - spec/wavefront-cli/commands/window_spec.rb
500
- - spec/wavefront-cli/commands/write_spec.rb
501
- - spec/wavefront-cli/config_spec.rb
502
- - spec/wavefront-cli/controller_spec.rb
503
- - spec/wavefront-cli/dashboard_spec.rb
504
- - spec/wavefront-cli/derivedmetric_spec.rb
505
- - spec/wavefront-cli/display/base_spec.rb
506
- - spec/wavefront-cli/display/printer/long_spec.rb
507
- - spec/wavefront-cli/display/printer/terse_spec.rb
508
- - spec/wavefront-cli/event_spec.rb
509
- - spec/wavefront-cli/event_store_spec.rb
510
- - spec/wavefront-cli/externallink_spec.rb
511
- - spec/wavefront-cli/integration_spec.rb
512
- - spec/wavefront-cli/maintenancewindow_spec.rb
513
- - spec/wavefront-cli/message_spec.rb
514
- - spec/wavefront-cli/metric_spec.rb
515
- - spec/wavefront-cli/notificant_spec.rb
516
- - spec/wavefront-cli/opt_handler_spec.rb
517
- - spec/wavefront-cli/output/csv/query_spec.rb
518
- - spec/wavefront-cli/output/csv_spec.rb
519
- - spec/wavefront-cli/output/hcl_spec.rb
520
- - spec/wavefront-cli/output/helpers.rb
521
- - spec/wavefront-cli/output/json_spec.rb
522
- - spec/wavefront-cli/output/ruby_spec.rb
523
- - spec/wavefront-cli/output/wavefront/query_spec.rb
524
- - spec/wavefront-cli/output/wavefront_spec.rb
525
- - spec/wavefront-cli/output/yaml_spec.rb
526
- - spec/wavefront-cli/proxy_spec.rb
527
- - spec/wavefront-cli/query_spec.rb
528
- - spec/wavefront-cli/resources/display/alert-human-long
529
- - spec/wavefront-cli/resources/display/alert-input.json
530
- - spec/wavefront-cli/resources/display/alerts-human-terse
531
- - spec/wavefront-cli/resources/display/alerts-input.json
532
- - spec/wavefront-cli/resources/display/user-human-long
533
- - spec/wavefront-cli/resources/display/user-human-long-no_sep
534
- - spec/wavefront-cli/resources/display/user-input.json
535
- - spec/wavefront-cli/resources/imports/alert.json
536
- - spec/wavefront-cli/resources/imports/dashboard.json
537
- - spec/wavefront-cli/resources/imports/derivedmetric.json
538
- - spec/wavefront-cli/resources/imports/notificant.json
539
- - spec/wavefront-cli/resources/imports/window.json
540
- - spec/wavefront-cli/resources/malformed.conf
541
- - spec/wavefront-cli/resources/responses/README.md
542
- - spec/wavefront-cli/resources/responses/alert-list.json
543
- - spec/wavefront-cli/resources/responses/backups.json
544
- - spec/wavefront-cli/resources/responses/cloudintegration-list.json
545
- - spec/wavefront-cli/resources/responses/dashboard-list.json
546
- - spec/wavefront-cli/resources/responses/derivedmetric-list.json
547
- - spec/wavefront-cli/resources/responses/event-list.json
548
- - spec/wavefront-cli/resources/responses/integration-list.json
549
- - spec/wavefront-cli/resources/responses/link-list.json
550
- - spec/wavefront-cli/resources/responses/notificant-list.json
551
- - spec/wavefront-cli/resources/responses/proxy-list.json
552
- - spec/wavefront-cli/resources/responses/query-cpu.json
553
- - spec/wavefront-cli/resources/responses/query.json
554
- - spec/wavefront-cli/resources/responses/savedsearch-list.json
555
- - spec/wavefront-cli/resources/responses/usage-export-csv.json
556
- - spec/wavefront-cli/resources/responses/user-validate.json
557
- - spec/wavefront-cli/resources/responses/usergroup-list.json
558
- - spec/wavefront-cli/resources/responses/webhook-list.json
559
- - spec/wavefront-cli/resources/responses/window-list.json
560
- - spec/wavefront-cli/resources/sample_query_response.json
561
- - spec/wavefront-cli/resources/sample_raw_query_response.json
562
- - spec/wavefront-cli/resources/updates/alert.json
563
- - spec/wavefront-cli/resources/updates/dashboard.json
564
- - spec/wavefront-cli/resources/wavefront.conf
565
- - spec/wavefront-cli/role_spec.rb
566
- - spec/wavefront-cli/savedsearch_spec.rb
567
- - spec/wavefront-cli/serviceaccount_spec.rb
568
- - spec/wavefront-cli/settings_spec.rb
569
- - spec/wavefront-cli/source_spec.rb
570
- - spec/wavefront-cli/spy_spec.rb
571
- - spec/wavefront-cli/stdlib/array_spec.rb
572
- - spec/wavefront-cli/stdlib/string_spec.rb
573
- - spec/wavefront-cli/usage_spec.rb
574
- - spec/wavefront-cli/usergroup_spec.rb
575
- - spec/wavefront-cli/webhook_spec.rb
576
- - spec/wavefront-cli/write_spec.rb
459
+ test_files: []
data/spec/spec_helper.rb DELETED
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'webmock/minitest'
5
- require 'spy/integration'
6
- require 'inifile'
7
- require 'minitest'
8
- require 'minitest/autorun'
9
- require 'minitest/spec'
10
- require 'pathname'
11
- require_relative '../lib/wavefront-cli/controller'
12
-
13
- unless defined?(CMD)
14
- ROOT = Pathname.new(__FILE__).dirname.parent
15
- CMD = 'wavefront'
16
- ENDPOINT = 'metrics.wavefront.com'
17
- TOKEN = '0123456789-ABCDEF'
18
- RES_DIR = Pathname.new(__FILE__).dirname + 'wavefront-cli' + 'resources'
19
- CF = RES_DIR + 'wavefront.conf'
20
- CF_VAL = IniFile.load(CF)
21
- JSON_POST_HEADERS = {
22
- 'Content-Type': 'application/json', Accept: 'application/json'
23
- }.freeze
24
- BAD_TAG = '*BAD_TAG*'
25
- HOME_CONFIG = Pathname.new(ENV['HOME']) + '.wavefront'
26
- end
27
-
28
- # Object returned by cmd_to_call. Has just enough methods to satisfy
29
- # the SDK
30
- #
31
- class DummyResponse
32
- def more_items?
33
- false
34
- end
35
-
36
- def response
37
- Map.new(items: [])
38
- end
39
-
40
- def empty?
41
- false
42
- end
43
-
44
- def status; end
45
- end
46
-
47
- CANNED_RESPONSE = DummyResponse.new
48
-
49
- # Unit tests
50
- #
51
- class CliMethodTest < MiniTest::Test
52
- attr_reader :wf
53
-
54
- def setup
55
- @wf = cliclass.new({})
56
- end
57
-
58
- def import_tester(word, have_fields, do_not_have_fields = [])
59
- input = wf.load_file(RES_DIR + 'imports' + "#{word}.json")
60
- x = wf.import_to_create(input)
61
- assert_instance_of(Hash, x)
62
- have_fields.each { |f| assert_includes(x.keys, f) }
63
- do_not_have_fields.each { |f| refute_includes(x.keys, f) }
64
- end
65
- end
66
-
67
- # stdlib extensions
68
- #
69
- class Hash
70
- # A quick way to deep-copy a hash.
71
- #
72
- def dup
73
- Marshal.load(Marshal.dump(self))
74
- end
75
- end
76
-
77
- require 'wavefront-sdk/core/response'
78
- require_relative '../lib/wavefront-cli/base'
79
-
80
- # For the given command word, loads up a canned API response and
81
- # feeds it in to the appropriate display class, running the given
82
- # method and returning standard out and standard error.
83
- #
84
- # @param word [String] command word, e.g. 'alert'
85
- # @param method [Symbol] display method to run, e.g. :do_list
86
- # @param klass [Class, Nil] CLI class. Worked out from the command
87
- # word in most cases, but must be overriden for two-word things.
88
- # @return [Array] [stdout, stderr]
89
- #
90
- def command_output(word, method, klass = nil, infile = nil)
91
- infile ||= "#{word}-list.json"
92
- json = IO.read(RES_DIR + 'responses' + infile)
93
- resp = Wavefront::Response.new(json, 200)
94
- klass ||= Object.const_get(format('WavefrontCli::%<class_word>s',
95
- class_word: word.capitalize))
96
- klass = klass.new(format: :human)
97
-
98
- capture_io { klass.display(resp, method) }
99
- end
100
-
101
- def test_list_output(word, klass = nil)
102
- it 'tests terse output' do
103
- out, err = command_output(word, :do_list_brief, klass)
104
- refute_empty(out)
105
- assert_empty(err)
106
- end
107
-
108
- it 'tests long output' do
109
- out, err = command_output(word, :do_list_long, klass)
110
- refute_empty(out)
111
- assert_empty(err)
112
- end
113
- end