bd6ed5c2c2
CI Gitea Reports Main / Config load (push) Successful in 17s
CI Main / Config load (push) Successful in 20s
CI Gitea Reports Main / Latest version (push) Successful in 17s
CI Main / Latest versio (push) Successful in 19s
ci-helm-build-push Helm push 0.2.0
CI Gitea Reports Main / Build & Push Helm chart (push) Successful in 33s
gitops/gitea-ci-library/gitea-reports GitOps: gitea-reports 0.2.0
CI Gitea Reports Main / GitOps (push) Successful in 33s
CI Gitea Reports Main / Report Summary (push) Successful in 3s
CI Main / Bats tests (push) Failing after 1m16s
CI Main / Cucumber tests (push) Failing after 1m22s
CI Main / Build & Push Docker (push) Has been skipped
CI Main / GitOps (push) Has been skipped
CI Main / Move provider version tag (push) Has been skipped
CI Main / Report Summary (push) Successful in 3s
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #48
80 lines
1.7 KiB
Bash
80 lines
1.7 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
setup() {
|
|
export CONF_FILE=$(mktemp)
|
|
export CI_CONF_FILE="$CONF_FILE"
|
|
}
|
|
|
|
teardown() {
|
|
rm -f "$CONF_FILE"
|
|
}
|
|
|
|
@test "missing config file → exit 1" {
|
|
export CI_CONF_FILE="/nonexistent/path/$(date +%s).conf"
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"ERROR"* ]]
|
|
}
|
|
|
|
@test "empty value in config → exit 1" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
SOME_KEY=
|
|
EOF
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"empty"* ]]
|
|
}
|
|
|
|
@test "invalid URL in config → exit 1" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
API_URL=not-a-url
|
|
EOF
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"URL"* ]]
|
|
}
|
|
|
|
@test "missing GITEA_TOKEN secret → exit 1" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
SOME_KEY=ok
|
|
EOF
|
|
unset GITEA_TOKEN
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"GITEA_TOKEN"* ]]
|
|
}
|
|
|
|
@test "missing REPORTS_PUBLISH_TOKEN secret → exit 1" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
SOME_KEY=ok
|
|
EOF
|
|
export GITEA_TOKEN="sometoken"
|
|
unset REPORTS_PUBLISH_TOKEN
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"REPORTS_PUBLISH_TOKEN"* ]]
|
|
}
|
|
|
|
@test "valid config and all secrets → exit 0" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
API_URL=https://example.com
|
|
ANOTHER=https://test.fi
|
|
EOF
|
|
export GITEA_TOKEN="sometoken"
|
|
export REPORTS_PUBLISH_TOKEN="sometoken"
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "comment and blank lines are ignored → exit 0" {
|
|
cat > "$CONF_FILE" <<EOF
|
|
# this is a comment
|
|
|
|
VALID_URL=https://example.com
|
|
EOF
|
|
export GITEA_TOKEN="sometoken"
|
|
export REPORTS_PUBLISH_TOKEN="sometoken"
|
|
run bash scripts/ci-validate.sh
|
|
[ "$status" -eq 0 ]
|
|
}
|