Test fixture for url fetcher

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-12-17 15:34:38 -05:00
parent 1eb33049e4
commit ed209643f3
8 changed files with 49 additions and 6 deletions

View file

@ -0,0 +1 @@
include_controls("url-deps-on-missing")

View file

@ -0,0 +1,5 @@
control "local-dep-01" do
describe "a string" do
it { should cmp "a string" }
end
end

View file

@ -0,0 +1,9 @@
name: local-dep-on-bad-url-archive
license: Apache-2.0
summary: An InSpec profile that depends on an archive that has unresolvable URL deps
version: 0.1.0
supports:
platform: os
depends:
- name: url-deps-on-missing
path: ../url-deps-on-missing-0.1.0.tar.gz

View file

@ -0,0 +1,5 @@
control "deps-on-missing-01" do
describe "a string" do
it { should cmp "a string" }
end
end

View file

@ -0,0 +1 @@
include_controls("inspec-test-profile-missing")

View file

@ -0,0 +1,10 @@
name: url-deps-on-missing
maintainer: InSpec Team
license: Apache-2.0
summary: An InSpec profile that has a dependency on an unresolvable URL
version: 0.1.0
supports:
platform: os
depends:
- name: inspec-test-profile-missing
url: https://github.com/inspec/inspec-test-profile-missing/archive/0.1.0.tar.gz

View file

@ -58,19 +58,31 @@ describe "the fetchers" do
# Refs #4727
describe "when a archive is available of an unfetchable profile with --airgap" do
let(:invocation) { "archive #{path} --airgap" }
let(:path) { "#{fetcher_profiles}/local-dep-on-bad-git-archive" }
let(:invocation) { "archive #{fetcher_profiles}/#{profile_name} --airgap" }
def teardown
FileUtils.rm_rf "#{path}/vendor"
FileUtils.rm_rf "#{fetcher_profiles}/local-dep-on-bad-git-archive-0.1.0.tar.gz"
FileUtils.rm_rf "#{fetcher_profiles}/#{profile_name}/vendor"
FileUtils.rm "#{profile_name}-0.1.0.tar.gz"
end
it "should be able to create a new archive wrapping the profile" do
# Cannot be parallelized - must purge cache to test properly
def assert_archive_worked(run_result)
_(run_result.stderr).must_be_empty
_(run_result.stdout).must_include "Finished archive generation"
assert_exit_code(0, run_result)
end
describe "when using a git fetcher" do
let(:profile_name) { "local-dep-on-bad-git-archive" }
it "should be able to create a new archive wrapping the profile" do
assert_archive_worked(run_result)
end
end
describe "when using a url fetcher" do
let(:profile_name) { "local-dep-on-bad-url-archive" }
it "should be able to create a new archive wrapping the profile" do
assert_archive_worked(run_result)
end
end
end
end