2019-04-03 07:44:39 +00:00
|
|
|
require 'inspec/utils/telemetry'
|
2019-05-18 21:13:55 +00:00
|
|
|
require 'helper'
|
2019-04-03 07:44:39 +00:00
|
|
|
|
|
|
|
class TestTelemetryGlobalMethods < Minitest::Test
|
|
|
|
def setup
|
|
|
|
@collector = Inspec::Telemetry::Collector.instance
|
2019-05-08 05:37:43 +00:00
|
|
|
@collector.load_config(Inspec::Config.mock('enable_telemetry'=>true))
|
2019-05-08 07:36:45 +00:00
|
|
|
@collector.reset!
|
2019-04-03 07:44:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_record_telemetry_data
|
|
|
|
assert Inspec.record_telemetry_data(:deprecation_group, 'serverspec_compat')
|
|
|
|
|
|
|
|
depgrp = @collector.find_or_create_data_series(:deprecation_group)
|
|
|
|
assert_equal ['serverspec_compat'], depgrp.data
|
|
|
|
assert_equal :deprecation_group, depgrp.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_record_telemetry_data_with_block
|
|
|
|
Inspec.record_telemetry_data(:deprecation_group) do
|
|
|
|
'serverspec_compat'
|
|
|
|
end
|
|
|
|
|
|
|
|
depgrp = @collector.find_or_create_data_series(:deprecation_group)
|
|
|
|
assert_equal ['serverspec_compat'], depgrp.data
|
|
|
|
assert_equal :deprecation_group, depgrp.name
|
|
|
|
end
|
2019-05-03 23:13:45 +00:00
|
|
|
|
|
|
|
def test_telemetry_disabled
|
|
|
|
@collector.load_config(Inspec::Config.mock(telemetry: false))
|
|
|
|
refute Inspec.record_telemetry_data(:deprecation_group, 'serverspec_compat')
|
|
|
|
end
|
2019-04-03 07:44:39 +00:00
|
|
|
end
|