wavefront-cli 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +1 -14
- data/.travis.yml +4 -4
- data/Gemfile +2 -0
- data/HISTORY.md +82 -60
- data/Rakefile +2 -0
- data/bin/wf +1 -0
- data/lib/wavefront-cli/alert.rb +13 -5
- data/lib/wavefront-cli/apitoken.rb +2 -0
- data/lib/wavefront-cli/base.rb +95 -47
- data/lib/wavefront-cli/cloudintegration.rb +6 -0
- data/lib/wavefront-cli/command_mixins/acl.rb +6 -1
- data/lib/wavefront-cli/command_mixins/tag.rb +2 -0
- data/lib/wavefront-cli/commands/.rubocop.yml +3 -4
- data/lib/wavefront-cli/commands/alert.rb +2 -1
- data/lib/wavefront-cli/commands/apitoken.rb +6 -0
- data/lib/wavefront-cli/commands/base.rb +30 -21
- data/lib/wavefront-cli/commands/cloudintegration.rb +2 -0
- data/lib/wavefront-cli/commands/config.rb +2 -0
- data/lib/wavefront-cli/commands/dashboard.rb +2 -0
- data/lib/wavefront-cli/commands/derivedmetric.rb +2 -0
- data/lib/wavefront-cli/commands/event.rb +3 -1
- data/lib/wavefront-cli/commands/integration.rb +2 -1
- data/lib/wavefront-cli/commands/link.rb +2 -0
- data/lib/wavefront-cli/commands/message.rb +2 -0
- data/lib/wavefront-cli/commands/metric.rb +2 -0
- data/lib/wavefront-cli/commands/notificant.rb +2 -0
- data/lib/wavefront-cli/commands/proxy.rb +2 -0
- data/lib/wavefront-cli/commands/query.rb +2 -0
- data/lib/wavefront-cli/commands/savedsearch.rb +2 -0
- data/lib/wavefront-cli/commands/serviceaccount.rb +58 -0
- data/lib/wavefront-cli/commands/settings.rb +2 -0
- data/lib/wavefront-cli/commands/source.rb +3 -1
- data/lib/wavefront-cli/commands/user.rb +4 -1
- data/lib/wavefront-cli/commands/usergroup.rb +3 -0
- data/lib/wavefront-cli/commands/webhook.rb +2 -0
- data/lib/wavefront-cli/commands/window.rb +2 -0
- data/lib/wavefront-cli/commands/write.rb +2 -0
- data/lib/wavefront-cli/config.rb +23 -12
- data/lib/wavefront-cli/constants.rb +10 -4
- data/lib/wavefront-cli/controller.rb +53 -22
- data/lib/wavefront-cli/dashboard.rb +3 -0
- data/lib/wavefront-cli/derivedmetric.rb +12 -11
- data/lib/wavefront-cli/display/alert.rb +7 -4
- data/lib/wavefront-cli/display/apitoken.rb +2 -0
- data/lib/wavefront-cli/display/base.rb +34 -8
- data/lib/wavefront-cli/display/cloudintegration.rb +4 -2
- data/lib/wavefront-cli/display/dashboard.rb +2 -0
- data/lib/wavefront-cli/display/derivedmetric.rb +2 -0
- data/lib/wavefront-cli/display/distribution.rb +2 -0
- data/lib/wavefront-cli/display/event.rb +2 -0
- data/lib/wavefront-cli/display/externallink.rb +2 -0
- data/lib/wavefront-cli/display/integration.rb +2 -0
- data/lib/wavefront-cli/display/maintenancewindow.rb +2 -0
- data/lib/wavefront-cli/display/message.rb +7 -3
- data/lib/wavefront-cli/display/metric.rb +3 -1
- data/lib/wavefront-cli/display/notificant.rb +3 -1
- data/lib/wavefront-cli/display/printer/long.rb +36 -11
- data/lib/wavefront-cli/display/printer/sparkline.rb +3 -0
- data/lib/wavefront-cli/display/printer/terse.rb +6 -1
- data/lib/wavefront-cli/display/proxy.rb +2 -0
- data/lib/wavefront-cli/display/query.rb +35 -24
- data/lib/wavefront-cli/display/savedsearch.rb +2 -0
- data/lib/wavefront-cli/display/serviceaccount.rb +60 -0
- data/lib/wavefront-cli/display/settings.rb +2 -0
- data/lib/wavefront-cli/display/source.rb +18 -4
- data/lib/wavefront-cli/display/user.rb +56 -10
- data/lib/wavefront-cli/display/usergroup.rb +25 -19
- data/lib/wavefront-cli/display/webhook.rb +2 -0
- data/lib/wavefront-cli/display/write.rb +6 -2
- data/lib/wavefront-cli/event.rb +83 -62
- data/lib/wavefront-cli/exception.rb +3 -0
- data/lib/wavefront-cli/externallink.rb +6 -4
- data/lib/wavefront-cli/integration.rb +2 -0
- data/lib/wavefront-cli/maintenancewindow.rb +28 -17
- data/lib/wavefront-cli/message.rb +4 -0
- data/lib/wavefront-cli/metric.rb +4 -1
- data/lib/wavefront-cli/notificant.rb +2 -0
- data/lib/wavefront-cli/opt_handler.rb +2 -0
- data/lib/wavefront-cli/output/base.rb +8 -3
- data/lib/wavefront-cli/output/csv.rb +2 -0
- data/lib/wavefront-cli/output/csv/base.rb +2 -0
- data/lib/wavefront-cli/output/csv/query.rb +14 -7
- data/lib/wavefront-cli/output/hcl.rb +2 -0
- data/lib/wavefront-cli/output/hcl/alert.rb +2 -0
- data/lib/wavefront-cli/output/hcl/base.rb +10 -4
- data/lib/wavefront-cli/output/hcl/dashboard.rb +17 -8
- data/lib/wavefront-cli/output/hcl/notificant.rb +2 -0
- data/lib/wavefront-cli/output/hcl/stdlib/array.rb +2 -0
- data/lib/wavefront-cli/output/hcl/stdlib/string.rb +2 -0
- data/lib/wavefront-cli/output/json.rb +2 -0
- data/lib/wavefront-cli/output/ruby.rb +2 -0
- data/lib/wavefront-cli/output/wavefront.rb +2 -0
- data/lib/wavefront-cli/output/wavefront/query.rb +7 -4
- data/lib/wavefront-cli/output/yaml.rb +2 -0
- data/lib/wavefront-cli/proxy.rb +15 -3
- data/lib/wavefront-cli/query.rb +14 -12
- data/lib/wavefront-cli/savedsearch.rb +2 -0
- data/lib/wavefront-cli/serviceaccount.rb +179 -0
- data/lib/wavefront-cli/settings.rb +2 -0
- data/lib/wavefront-cli/source.rb +2 -0
- data/lib/wavefront-cli/stdlib/array.rb +3 -0
- data/lib/wavefront-cli/stdlib/string.rb +17 -11
- data/lib/wavefront-cli/user.rb +10 -4
- data/lib/wavefront-cli/usergroup.rb +4 -2
- data/lib/wavefront-cli/version.rb +3 -1
- data/lib/wavefront-cli/webhook.rb +2 -0
- data/lib/wavefront-cli/write.rb +80 -46
- data/spec/.rubocop.yml +3 -16
- data/spec/constants.rb +21 -0
- data/spec/spec_helper.rb +8 -422
- data/spec/support/command_base.rb +82 -0
- data/spec/support/minitest_assertions.rb +262 -0
- data/spec/support/output_tester.rb +32 -0
- data/spec/support/supported_commands.rb +19 -0
- data/spec/test_mixins/acl.rb +169 -0
- data/spec/test_mixins/delete.rb +25 -0
- data/spec/test_mixins/deleteundelete.rb +106 -0
- data/spec/test_mixins/describe.rb +24 -0
- data/spec/test_mixins/dump.rb +43 -0
- data/spec/test_mixins/general.rb +11 -0
- data/spec/test_mixins/history.rb +35 -0
- data/spec/test_mixins/import.rb +65 -0
- data/spec/test_mixins/list.rb +29 -0
- data/spec/test_mixins/search.rb +98 -0
- data/spec/test_mixins/set.rb +47 -0
- data/spec/test_mixins/tag.rb +99 -0
- data/spec/wavefront-cli/alert_spec.rb +288 -111
- data/spec/wavefront-cli/apitoken_spec.rb +53 -24
- data/spec/wavefront-cli/base_spec.rb +9 -27
- data/spec/wavefront-cli/cloudintegration_spec.rb +65 -29
- data/spec/wavefront-cli/commands/alert_spec.rb +1 -0
- data/spec/wavefront-cli/commands/base_spec.rb +15 -13
- data/spec/wavefront-cli/commands/cloudintegration_spec.rb +1 -0
- data/spec/wavefront-cli/commands/config_spec.rb +3 -0
- data/spec/wavefront-cli/commands/dashboard_spec.rb +1 -0
- data/spec/wavefront-cli/commands/derivedmetric_spec.rb +1 -0
- data/spec/wavefront-cli/commands/event_spec.rb +1 -0
- data/spec/wavefront-cli/commands/link_spec.rb +1 -0
- data/spec/wavefront-cli/commands/message_spec.rb +1 -0
- data/spec/wavefront-cli/commands/metric_spec.rb +1 -0
- data/spec/wavefront-cli/commands/proxy_spec.rb +1 -0
- data/spec/wavefront-cli/commands/query_spec.rb +1 -0
- data/spec/wavefront-cli/commands/webhook_spec.rb +1 -0
- data/spec/wavefront-cli/commands/window_spec.rb +1 -0
- data/spec/wavefront-cli/commands/write_spec.rb +1 -0
- data/spec/wavefront-cli/config_spec.rb +25 -14
- data/spec/wavefront-cli/controller_spec.rb +13 -3
- data/spec/wavefront-cli/dashboard_spec.rb +125 -76
- data/spec/wavefront-cli/derivedmetric_spec.rb +83 -67
- data/spec/wavefront-cli/display/base_spec.rb +5 -7
- data/spec/wavefront-cli/display/printer/long_spec.rb +20 -16
- data/spec/wavefront-cli/display/printer/terse_spec.rb +5 -4
- data/spec/wavefront-cli/event_spec.rb +360 -18
- data/spec/wavefront-cli/externallink_spec.rb +92 -58
- data/spec/wavefront-cli/integration_spec.rb +129 -31
- data/spec/wavefront-cli/maintenancewindow_spec.rb +270 -32
- data/spec/wavefront-cli/message_spec.rb +73 -30
- data/spec/wavefront-cli/metric_spec.rb +60 -22
- data/spec/wavefront-cli/notificant_spec.rb +45 -32
- data/spec/wavefront-cli/opt_handler_spec.rb +4 -1
- data/spec/wavefront-cli/output/csv/query_spec.rb +21 -19
- data/spec/wavefront-cli/output/csv_spec.rb +5 -2
- data/spec/wavefront-cli/output/hcl_spec.rb +5 -2
- data/spec/wavefront-cli/output/helpers.rb +18 -0
- data/spec/wavefront-cli/output/json_spec.rb +3 -1
- data/spec/wavefront-cli/output/ruby_spec.rb +3 -1
- data/spec/wavefront-cli/output/wavefront/query_spec.rb +3 -1
- data/spec/wavefront-cli/output/wavefront_spec.rb +6 -4
- data/spec/wavefront-cli/output/yaml_spec.rb +3 -1
- data/spec/wavefront-cli/proxy_spec.rb +49 -27
- data/spec/wavefront-cli/query_spec.rb +174 -92
- data/spec/wavefront-cli/resources/responses/query.json +1 -0
- data/spec/wavefront-cli/resources/updates/alert.json +15 -0
- data/spec/wavefront-cli/resources/updates/dashboard.json +1 -0
- data/spec/wavefront-cli/savedsearch_spec.rb +35 -18
- data/spec/wavefront-cli/serviceaccount_spec.rb +399 -0
- data/spec/wavefront-cli/settings_spec.rb +42 -11
- data/spec/wavefront-cli/source_spec.rb +120 -23
- data/spec/wavefront-cli/stdlib/array_spec.rb +2 -1
- data/spec/wavefront-cli/stdlib/string_spec.rb +9 -6
- data/spec/wavefront-cli/user_spec.rb +278 -108
- data/spec/wavefront-cli/usergroup_spec.rb +152 -102
- data/spec/wavefront-cli/webhook_spec.rb +30 -15
- data/spec/wavefront-cli/write_spec.rb +25 -1
- data/wavefront-cli.gemspec +5 -3
- metadata +65 -21
- data/spec/wavefront-cli/commands/spec_helper.rb +0 -3
- data/spec/wavefront-cli/display/spec_helper.rb +0 -3
|
@@ -1,35 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
require_relative '../support/command_base'
|
|
5
|
+
require_relative '../../lib/wavefront-cli/apitoken'
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
# Ensure 'apitoken' commands produce the correct API calls.
|
|
8
|
+
#
|
|
9
|
+
class ApiTokenEndToEndTest < EndToEndTest
|
|
10
|
+
include WavefrontCliTest::Delete
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
def test_list
|
|
13
|
+
quietly { assert_cmd_gets('list', '/api/v2/apitoken') }
|
|
14
|
+
assert_usage('list --offset 4')
|
|
15
|
+
assert_abort_on_missing_creds('list')
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
assert_noop('list',
|
|
18
|
+
'uri: GET https://default.wavefront.com/api/v2/apitoken')
|
|
19
|
+
end
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
def test_create
|
|
22
|
+
quietly { assert_cmd_posts('create', '/api/v2/apitoken') }
|
|
23
|
+
assert_abort_on_missing_creds('create')
|
|
24
|
+
assert_noop('create',
|
|
25
|
+
'uri: POST https://default.wavefront.com/api/v2/apitoken',
|
|
26
|
+
'body: null')
|
|
27
|
+
end
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
def _test_rename
|
|
30
|
+
assert_cmd_puts("rename #{id} newname", "/api/v2/apitoken/#{id}",
|
|
31
|
+
tokenID: id, tokenName: 'newname')
|
|
32
|
+
assert_invalid_id("rename #{invalid_id} newname")
|
|
33
|
+
assert_abort_on_missing_creds("rename #{id} newname")
|
|
20
34
|
|
|
21
|
-
|
|
35
|
+
assert_noop(
|
|
36
|
+
"rename #{id} newname",
|
|
37
|
+
"uri: PUT https://default.wavefront.com/api/v2/apitoken/#{id}",
|
|
38
|
+
'body: {"tokenID":"17db4cc1-65f6-40a8-a1fa-6fcae460c4bd",' \
|
|
39
|
+
'"tokenName":"newname"}'
|
|
40
|
+
)
|
|
41
|
+
end
|
|
22
42
|
|
|
23
|
-
|
|
24
|
-
["GET https://metrics.wavefront.com/api/v2/#{word}"], k)
|
|
25
|
-
cmd_noop(word, 'create',
|
|
26
|
-
["POST https://metrics.wavefront.com/api/v2/#{word}"], k)
|
|
27
|
-
cmd_noop(word, "delete #{id}",
|
|
28
|
-
["DELETE https://metrics.wavefront.com/api/v2/#{word}/#{id}"], k)
|
|
43
|
+
private
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
def id
|
|
46
|
+
'17db4cc1-65f6-40a8-a1fa-6fcae460c4bd'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def invalid_id
|
|
50
|
+
'__BAD__'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def cmd_word
|
|
54
|
+
'apitoken'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def sdk_class_name
|
|
58
|
+
'ApiToken'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def friendly_name
|
|
62
|
+
'api token'
|
|
63
|
+
end
|
|
35
64
|
end
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
require 'minitest/autorun'
|
|
4
5
|
require_relative '../../lib/wavefront-cli/alert'
|
|
5
|
-
|
|
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
|
|
6
|
+
require_relative '../../lib/wavefront-cli/version'
|
|
28
7
|
|
|
29
8
|
# Since I tidied up the file layout in wavefront-sdk, there's no
|
|
30
9
|
# longer a 1:1 mapping of CLI and SDK classes. wavefront-sdk/base is
|
|
@@ -37,13 +16,16 @@ class WavefrontCliBaseTest < MiniTest::Test
|
|
|
37
16
|
attr_reader :wf, :wf_cmd
|
|
38
17
|
|
|
39
18
|
def setup
|
|
40
|
-
@wf = WavefrontCli::Alert.new(
|
|
19
|
+
@wf = WavefrontCli::Alert.new(endpoint: 'test.wavefront.com',
|
|
20
|
+
token: '0123456789-ABCDEF',
|
|
21
|
+
debug: false,
|
|
22
|
+
noop: true)
|
|
41
23
|
end
|
|
42
24
|
|
|
43
25
|
def test_mk_creds
|
|
44
26
|
assert_equal({ endpoint: 'test.wavefront.com',
|
|
45
|
-
token:
|
|
46
|
-
agent:
|
|
27
|
+
token: '0123456789-ABCDEF',
|
|
28
|
+
agent: "wavefront-cli-#{WF_CLI_VERSION}" },
|
|
47
29
|
wf.mk_creds)
|
|
48
30
|
end
|
|
49
31
|
|
|
@@ -1,34 +1,70 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require_relative '../
|
|
4
|
+
require_relative '../support/command_base'
|
|
4
5
|
require_relative '../../lib/wavefront-cli/cloudintegration'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
# Ensure 'cloudintegration' commands produce the correct API calls.
|
|
8
|
+
#
|
|
9
|
+
class CloudIntegrationEndToEndTest < EndToEndTest
|
|
10
|
+
include WavefrontCliTest::DeleteUndelete
|
|
11
|
+
include WavefrontCliTest::Describe
|
|
12
|
+
include WavefrontCliTest::Dump
|
|
13
|
+
include WavefrontCliTest::List
|
|
14
|
+
# include WavefrontCliTest::Import
|
|
15
|
+
include WavefrontCliTest::Search
|
|
16
|
+
|
|
17
|
+
def test_enable
|
|
18
|
+
assert_repeated_output("Enabled '#{id}'.") do
|
|
19
|
+
assert_cmd_posts("enable #{id}",
|
|
20
|
+
"/api/v2/cloudintegration/#{id}/enable")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
assert_invalid_id("enable #{invalid_id}")
|
|
24
|
+
assert_usage('enable')
|
|
25
|
+
assert_abort_on_missing_creds("enable #{id}")
|
|
26
|
+
|
|
27
|
+
assert_noop("enable #{id}",
|
|
28
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
|
29
|
+
"cloudintegration/#{id}/enable",
|
|
30
|
+
'body: null')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_disable
|
|
34
|
+
assert_repeated_output("Disabled '#{id}'.") do
|
|
35
|
+
assert_cmd_posts("disable #{id}",
|
|
36
|
+
"/api/v2/cloudintegration/#{id}/disable")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
assert_invalid_id("disable #{invalid_id}")
|
|
40
|
+
assert_usage('disable')
|
|
41
|
+
assert_abort_on_missing_creds("disable #{id}")
|
|
42
|
+
|
|
43
|
+
assert_noop("disable #{id}",
|
|
44
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
|
45
|
+
"cloudintegration/#{id}/disable",
|
|
46
|
+
'body: null')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def id
|
|
52
|
+
'3b56f61d-1a79-46f6-905c-d75a0f613d10'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def invalid_id
|
|
56
|
+
'__BAD__'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def cmd_word
|
|
60
|
+
'cloudintegration'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def sdk_class_name
|
|
64
|
+
'CloudIntegration'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def friendly_name
|
|
68
|
+
'cloud integration'
|
|
69
|
+
end
|
|
34
70
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require 'pathname'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require_relative 'spec_helper'
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
require_relative '../../constants'
|
|
7
|
+
require_relative '../../../lib/wavefront-cli/commands/base'
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# Abstract class for testing commands
|
|
10
10
|
#
|
|
11
11
|
class WavefrontCommmandBaseTest < MiniTest::Test
|
|
12
12
|
attr_reader :wf, :col_width, :skip_cmd
|
|
@@ -70,6 +70,7 @@ class WavefrontCommmandBaseTest < MiniTest::Test
|
|
|
70
70
|
|
|
71
71
|
wf.commands(600).split("\n")[1..-1].each do |c|
|
|
72
72
|
next if skip_cmd && c.match(skip_cmd)
|
|
73
|
+
|
|
73
74
|
assert_match(/^ \w+/, c)
|
|
74
75
|
assert_includes(c, CMN) unless c =~ /--help$/
|
|
75
76
|
end
|
|
@@ -77,38 +78,39 @@ class WavefrontCommmandBaseTest < MiniTest::Test
|
|
|
77
78
|
|
|
78
79
|
def test_options
|
|
79
80
|
assert wf.options(600).start_with?("Global options:\n")
|
|
80
|
-
assert_match(/\nOptions
|
|
81
|
+
assert_match(/\nOptions:/, wf.options)
|
|
81
82
|
|
|
82
83
|
wf.options(600).split("\n")[1..-1].each do |o|
|
|
83
84
|
next if o == 'Global options:' || o == 'Options:' || o.empty?
|
|
85
|
+
|
|
84
86
|
assert_instance_of(String, o)
|
|
85
87
|
assert_match(/^ -\w, --\w+/, o)
|
|
86
88
|
refute o.end_with?('.')
|
|
87
89
|
end
|
|
88
90
|
|
|
89
|
-
assert_equal(wf.options.split("\n").select(&:empty?).size
|
|
91
|
+
assert_equal(1, wf.options.split("\n").select(&:empty?).size)
|
|
90
92
|
end
|
|
91
93
|
|
|
92
94
|
def test_opt_row
|
|
93
95
|
assert_equal(wf.opt_row('-s, --short short option', 10),
|
|
94
|
-
|
|
96
|
+
' -s, --short short option')
|
|
95
97
|
assert_equal(wf.opt_row('-s, --short short option', 8),
|
|
96
|
-
|
|
98
|
+
' -s, --short short option')
|
|
97
99
|
assert_equal(wf.opt_row(
|
|
98
100
|
'-l, --longoption a long option with a quite ' \
|
|
99
101
|
'long description which needs folding', 15
|
|
100
|
-
|
|
102
|
+
),
|
|
101
103
|
' -l, --longoption a long option with a quite long ' \
|
|
102
|
-
"description which\n needs folding
|
|
104
|
+
"description which\n needs folding")
|
|
103
105
|
assert_equal(wf.opt_row(
|
|
104
106
|
'-h, --hugeoption an option with a very long, far ' \
|
|
105
107
|
'too verbose description which is going need folding ' \
|
|
106
108
|
'more than one time, let me tell you', 12
|
|
107
|
-
|
|
109
|
+
),
|
|
108
110
|
' -h, --hugeoption an option with a very long, far too ' \
|
|
109
111
|
"verbose description\n which is going " \
|
|
110
112
|
'need folding more than one time, let me tell' \
|
|
111
|
-
"\n you
|
|
113
|
+
"\n you")
|
|
112
114
|
end
|
|
113
115
|
|
|
114
116
|
def test_option_column_width
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require 'pathname'
|
|
4
5
|
require_relative(File.join('../../../lib/wavefront-cli/commands',
|
|
@@ -21,6 +22,7 @@ class WavefrontCommmandConfigTest < WavefrontCommmandBaseTest
|
|
|
21
22
|
|
|
22
23
|
wf.options(600).split("\n")[1..-1].each do |o|
|
|
23
24
|
next if o == 'Global options:' || o == 'Options:' || o.empty?
|
|
25
|
+
|
|
24
26
|
assert_instance_of(String, o)
|
|
25
27
|
assert_match(/^ -\w, --\w+/, o)
|
|
26
28
|
refute o.end_with?('.')
|
|
@@ -35,6 +37,7 @@ class WavefrontCommmandConfigTest < WavefrontCommmandBaseTest
|
|
|
35
37
|
|
|
36
38
|
wf.commands(600).split("\n")[1..-1].each do |c|
|
|
37
39
|
next if skip_cmd && c.match(skip_cmd)
|
|
40
|
+
|
|
38
41
|
assert_match(/^ \w+/, c)
|
|
39
42
|
end
|
|
40
43
|
end
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
require_relative '../constants'
|
|
4
7
|
require_relative '../../lib/wavefront-cli/config'
|
|
5
8
|
|
|
6
9
|
DEF_CF = Pathname.new(ENV['HOME']) + '.wavefront'
|
|
7
10
|
CONF_TMP = Pathname.new('/tmp/outfile')
|
|
8
11
|
|
|
9
|
-
# Test
|
|
12
|
+
# Test CLI configuration command
|
|
10
13
|
#
|
|
11
14
|
class WavefrontCliConfigTest < MiniTest::Test
|
|
12
15
|
attr_reader :wf, :wfo, :wfn
|
|
@@ -18,9 +21,9 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
def test_do_location
|
|
21
|
-
assert_output(format("
|
|
24
|
+
assert_output(format("%<file>s\n", file: CF)) { wfo.do_location }
|
|
22
25
|
assert_output("/no/file\n") { wfn.do_location }
|
|
23
|
-
assert_output(format("
|
|
26
|
+
assert_output(format("%<file>s\n", file: DEF_CF)) { wf.do_location }
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def test_do_profiles
|
|
@@ -45,15 +48,23 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
45
48
|
|
|
46
49
|
def test_read_input
|
|
47
50
|
["value \n", " value\n", " value \t\n", "value\n"].each do |v|
|
|
48
|
-
STDIN.stub(:gets, v)
|
|
49
|
-
assert_equal('value', wf.read_input)
|
|
50
|
-
end
|
|
51
|
+
STDIN.stub(:gets, v) { assert_equal('value', wf.read_input) }
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
def test_base_config
|
|
55
|
-
assert_instance_of(IniFile,
|
|
56
|
-
|
|
56
|
+
out, err = capture_io { assert_instance_of(IniFile, wf.base_config) }
|
|
57
|
+
assert_empty(err)
|
|
58
|
+
|
|
59
|
+
if (Pathname.new(ENV['HOME']) + '.wavefront').exist?
|
|
60
|
+
assert_empty(out)
|
|
61
|
+
else
|
|
62
|
+
assert_match(/Creating new configuration file at/, out)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
out, err = capture_io { assert_instance_of(IniFile, wfo.base_config) }
|
|
66
|
+
assert_empty(err)
|
|
67
|
+
assert_empty(out)
|
|
57
68
|
|
|
58
69
|
assert_output('') { wfo.base_config }
|
|
59
70
|
assert_output("Creating new configuration file at /no/file.\n") do
|
|
@@ -98,12 +109,12 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
98
109
|
assert_equal('json', x[:prof]['format'])
|
|
99
110
|
end
|
|
100
111
|
|
|
112
|
+
assert_empty(err)
|
|
101
113
|
assert_match(/Creating profile 'prof'./, out)
|
|
102
114
|
assert_match(/Wavefront API token/, out)
|
|
103
115
|
assert_match(/Wavefront API endpoint/, out)
|
|
104
116
|
assert_match(/Wavefront proxy endpoint/, out)
|
|
105
117
|
assert_match(/default output format/, out)
|
|
106
|
-
assert_empty(err)
|
|
107
118
|
end
|
|
108
119
|
|
|
109
120
|
def test_create_profile_2
|
|
@@ -122,12 +133,12 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
122
133
|
assert_equal('human', x[:prof]['format'])
|
|
123
134
|
end
|
|
124
135
|
|
|
136
|
+
assert_empty(err)
|
|
125
137
|
assert_match(/Creating profile 'prof'./, out)
|
|
126
138
|
assert_match(/Wavefront API token/, out)
|
|
127
139
|
assert_match(/Wavefront API endpoint/, out)
|
|
128
140
|
assert_match(/Wavefront proxy endpoint/, out)
|
|
129
141
|
assert_match(/default output format/, out)
|
|
130
|
-
assert_empty(err)
|
|
131
142
|
end
|
|
132
143
|
|
|
133
144
|
def test_create_profile_3
|
|
@@ -141,9 +152,9 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
141
152
|
end
|
|
142
153
|
end
|
|
143
154
|
|
|
155
|
+
assert_empty(err)
|
|
144
156
|
assert_match(/Creating profile 'prof'./, out)
|
|
145
157
|
assert_match(/Wavefront API token/, out)
|
|
146
|
-
assert_empty(err)
|
|
147
158
|
end
|
|
148
159
|
|
|
149
160
|
def test_create_profile_4
|
|
@@ -157,9 +168,9 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
157
168
|
end
|
|
158
169
|
end
|
|
159
170
|
|
|
171
|
+
assert_empty(err)
|
|
160
172
|
assert_match(/Creating profile 'prof'./, out)
|
|
161
173
|
assert_match(/Wavefront API token/, out)
|
|
162
|
-
assert_empty(err)
|
|
163
174
|
end
|
|
164
175
|
|
|
165
176
|
def test_create_profile_5
|
|
@@ -173,9 +184,9 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
|
173
184
|
end
|
|
174
185
|
end
|
|
175
186
|
|
|
187
|
+
assert_empty(err)
|
|
176
188
|
assert_match(/Creating profile 'prof'./, out)
|
|
177
189
|
assert_match(/Wavefront API token/, out)
|
|
178
|
-
assert_empty(err)
|
|
179
190
|
end
|
|
180
191
|
|
|
181
192
|
def test_do_setup; end
|