2020-09-25 09:15:26 +00:00
|
|
|
require "functional/helper"
|
|
|
|
require "securerandom"
|
|
|
|
|
|
|
|
describe "inspec check" do
|
|
|
|
include FunctionalHelper
|
|
|
|
|
|
|
|
parallelize_me!
|
|
|
|
|
|
|
|
describe "inspec clear_cache" do
|
|
|
|
it "clears any existing cache" do
|
2020-12-01 13:05:55 +00:00
|
|
|
dirname = File.expand_path("~/.inspec/#{SecureRandom.hex(10)}/alt-cache")
|
2020-09-25 09:15:26 +00:00
|
|
|
unless File.directory?(dirname)
|
|
|
|
FileUtils.mkdir_p(dirname)
|
|
|
|
end
|
|
|
|
newfile = "#{dirname}/#{SecureRandom.hex(10)}.txt"
|
|
|
|
File.write(newfile, SecureRandom.hex(100))
|
|
|
|
|
|
|
|
assert !Dir.glob(newfile).empty?
|
|
|
|
|
2020-12-01 13:05:55 +00:00
|
|
|
out = inspec("clear_cache --vendor-cache=#{dirname}")
|
2020-09-25 09:15:26 +00:00
|
|
|
|
|
|
|
assert_empty Dir.glob(newfile)
|
|
|
|
assert_exit_code 0, out
|
|
|
|
_(out.stdout).must_include "== InSpec cache cleared successfully ==\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|