Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bats-lib methods from central repo #150

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/timing.properties

# Rego
policy/

# BATS
_test/test_helper/
3 changes: 0 additions & 3 deletions _test/_helpers.bash

This file was deleted.

9 changes: 9 additions & 0 deletions _test/bats-support-clone.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if [[ ! -d "_test/test_helper/bats-support" ]]; then
# Download bats-support dynamically so it doesnt need to be added into source
git clone https://github.com/ztombol/bats-support _test/test_helper/bats-support --depth 1
fi

if [[ ! -d "_test/test_helper/redhatcop-bats-library" ]]; then
# Download redhat-cop/bats-library dynamically so it doesnt need to be added into source
git clone https://github.com/redhat-cop/bats-library _test/test_helper/redhatcop-bats-library --depth 1
fi
141 changes: 101 additions & 40 deletions _test/conftest.sh
Original file line number Diff line number Diff line change
@@ -1,81 +1,142 @@
#!/usr/bin/env bats

load _helpers
load bats-support-clone
load test_helper/bats-support/load
load test_helper/redhatcop-bats-library/load

setup_file() {
rm -rf /tmp/rhcop
conftest_pull
}

@test "basic-dotnet-core/.openshift" {
run conftest test basic-dotnet-core/.openshift --output tap
print_err "$status" "$output"
tmp=$(split_files "basic-dotnet-core/.openshift")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "basic-nginx/.openshift" {
run conftest test basic-nginx/.openshift --output tap
print_err "$status" "$output"
[ "$status" -eq 0 ]
}
tmp=$(split_files "basic-nginx/.openshift")

@test "basic-spring-boot-tekton/.openshift" {
run conftest test basic-spring-boot-tekton/.openshift --output tap
print_err "$status" "$output"
namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "basic-spring-boot/.openshift basic-tomcat/.openshift" {
run conftest test basic-spring-boot/.openshift basic-tomcat/.openshift --output tap
print_err "$status" "$output"
@test "basic-spring-boot/.openshift" {
tmp=$(split_files "basic-spring-boot/.openshift")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "blue-green-spring/.openshift" {
run conftest test blue-green-spring/.openshift --output tap
print_err "$status" "$output"
@test "basic-spring-boot-tekton/.openshift" {
tmp=$(split_files "basic-spring-boot-tekton/.openshift")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "cucumber-selenium-grid/applier/projects" {
run conftest test cucumber-selenium-grid/applier/projects --output tap
print_err "$status" "$output"
@test "basic-tomcat/.openshift" {
tmp=$(split_files "basic-tomcat/.openshift")

namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "cucumber-selenium-grid/applier/templates" {
run conftest test cucumber-selenium-grid/applier/templates --output tap
print_err "$status" "$output"
@test "blue-green-spring/.openshift" {
tmp=$(split_files "blue-green-spring/.openshift")

namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "jenkins-s2i multi-cluster-multi-branch-jee/.openshift" {
run conftest test jenkins-s2i multi-cluster-multi-branch-jee/.openshift --output tap
print_err "$status" "$output"
@test "cucumber-selenium-grid/applier" {
tmp=$(split_files "cucumber-selenium-grid/applier")

namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "multi-cluster-spring-boot/image-mirror-example/.applier/projects" {
run conftest test multi-cluster-spring-boot/image-mirror-example/.applier/projects --output tap
print_err "$status" "$output"
@test "jenkins-s2i" {
tmp=$(split_files "jenkins-s2i")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "multi-cluster-spring-boot/image-mirror-example/.applier/templates" {
run conftest test multi-cluster-spring-boot/image-mirror-example/.applier/templates --output tap
print_err "$status" "$output"
@test "multi-cluster-multi-branch-jee/.openshift" {
tmp=$(split_files "multi-cluster-multi-branch-jee/.openshift")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "multi-cluster-spring-boot/skopeo-example/.applier/projects" {
run conftest test multi-cluster-spring-boot/skopeo-example/.applier/projects --output tap
print_err "$status" "$output"
@test "multi-cluster-spring-boot/image-mirror-example/.applier" {
tmp=$(split_files "multi-cluster-spring-boot/image-mirror-example/.applier")

namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "multi-cluster-spring-boot/skopeo-example/.applier/templates" {
run conftest test multi-cluster-spring-boot/skopeo-example/.applier/templates --output tap
print_err "$status" "$output"
@test "multi-cluster-spring-boot/skopeo-example/.applier" {
tmp=$(split_files "multi-cluster-spring-boot/skopeo-example/.applier")

namespaces=$(get_rego_namespaces "(?!ocp\.deprecated.ocp4_3\.buildconfig_jenkinspipeline_strategy)ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}

@test "secure-spring-boot/.openshift-applier/templates" {
run conftest test secure-spring-boot/.openshift-applier/templates --output tap
print_err "$status" "$output"
@test "secure-spring-boot/.openshift-applier" {
tmp=$(split_files "secure-spring-boot/.openshift-applier")

namespaces=$(get_rego_namespaces "ocp\.deprecated\.*")
cmd="conftest test ${tmp} --output tap ${namespaces}"
run ${cmd}

print_info "${status}" "${output}" "${cmd}" "${tmp}"
[ "$status" -eq 0 ]
}