inspec/test/unit/utils/telemetry/global_methods_test.rb
Miah Johnson d000f20f34 Update Collector#reset to clear telemetry_toggled_off
Updated the name of #reset -> #reset! as we are modifying state of a
singeton.

Signed-off-by: Miah Johnson <miah@chia-pet.org>
2019-05-08 00:36:45 -07:00

33 lines
1.1 KiB
Ruby

require 'inspec/utils/telemetry'
require_relative '../../../helper.rb'
class TestTelemetryGlobalMethods < Minitest::Test
def setup
@collector = Inspec::Telemetry::Collector.instance
@collector.load_config(Inspec::Config.mock('enable_telemetry'=>true))
@collector.reset!
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
def test_telemetry_disabled
@collector.load_config(Inspec::Config.mock(telemetry: false))
refute Inspec.record_telemetry_data(:deprecation_group, 'serverspec_compat')
end
end