Add a functional test to check Thor run context detection

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2020-05-24 23:50:10 -04:00
parent 45e3421595
commit 439c93b115
2 changed files with 20 additions and 5 deletions

View file

@ -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)

View file

@ -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