From 439c93b115bfbddcb1fddd5bc9e74994f676bc10 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Sun, 24 May 2020 23:50:10 -0400 Subject: [PATCH] Add a functional test to check Thor run context detection Signed-off-by: Clinton Wolfe --- lib/inspec/cli.rb | 11 ++++++----- test/functional/telemetry_test.rb | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 test/functional/telemetry_test.rb diff --git a/lib/inspec/cli.rb b/lib/inspec/cli.rb index e2d446efd..6fa5eae3d 100644 --- a/lib/inspec/cli.rb +++ b/lib/inspec/cli.rb @@ -375,6 +375,12 @@ class Inspec::InspecCLI < Inspec::BaseCLI puts "Valid schemas are #{Inspec::Schema::OutputSchema.names.join(", ")}" end + desc "run_context", "used to test run-context detection", hide: true + def run_context + require "inspec/utils/telemetry/run_context_probe" + puts Inspec::Telemetry::RunContextProbe.guess_run_context + end + desc "version", "prints the version of this tool" option :format, type: :string def version @@ -387,11 +393,6 @@ class Inspec::InspecCLI < Inspec::BaseCLI end map %w{-v --version} => :version - desc "nothing", "does nothing" - def nothing - puts "you did nothing" - end - private def run_command(opts) diff --git a/test/functional/telemetry_test.rb b/test/functional/telemetry_test.rb new file mode 100644 index 000000000..3ca9f6985 --- /dev/null +++ b/test/functional/telemetry_test.rb @@ -0,0 +1,14 @@ +require "functional/helper" + +describe "telemetry" do + include FunctionalHelper + parallelize_me! + + describe "detecting CLI runtime context" do + let(:run_result) { run_inspec_process("run_context") } + it "should detect cli context" do + _(run_result.stderr).must_equal "" + _(run_result.stdout).must_include "cli" + end + end +end