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
92 lines
2.4 KiB
Bash
92 lines
2.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
setup() {
|
|
source tests/helpers/mock-api.sh
|
|
export GITEA_API_URL="http://localhost:18080"
|
|
export GIT_PAGES_URL="http://localhost:18080"
|
|
export REPORTS_PUBLISH_TOKEN="publish-token-abc"
|
|
export GITHUB_REPOSITORY="test-owner/test-repo"
|
|
export GITHUB_SHA="abc123def456789012345678901234567890abcd"
|
|
export GITHUB_REF_NAME="main"
|
|
|
|
mkdir -p "unit-tests"
|
|
echo "<html>test</html>" > "unit-tests/index.html"
|
|
}
|
|
|
|
teardown() {
|
|
mock_stop
|
|
rm -rf "unit-tests" "sub"
|
|
}
|
|
|
|
@test "missing suite_path argument → exit 1" {
|
|
run bash scripts/publish-git-pages.sh ""
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"ERROR"* ]]
|
|
}
|
|
|
|
@test "missing GITHUB_REF_NAME → exit 1" {
|
|
unset GITHUB_REF_NAME
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"GITHUB_REF_NAME"* ]]
|
|
}
|
|
|
|
@test "missing GIT_PAGES_URL → exit 1" {
|
|
unset GIT_PAGES_URL
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"GIT_PAGES_URL"* ]]
|
|
}
|
|
|
|
@test "missing REPORTS_PUBLISH_TOKEN → exit 1" {
|
|
unset REPORTS_PUBLISH_TOKEN
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"REPORTS_PUBLISH_TOKEN"* ]]
|
|
}
|
|
|
|
@test "missing GITHUB_REPOSITORY → exit 1" {
|
|
unset GITHUB_REPOSITORY
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"GITHUB_REPOSITORY"* ]]
|
|
}
|
|
|
|
@test "suite path is not a directory → exit 1" {
|
|
run bash scripts/publish-git-pages.sh "nonexistent"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"not a directory"* ]]
|
|
}
|
|
|
|
@test "valid publish returns report base URL" {
|
|
mock_set_sequence '[
|
|
{"code":200,"body":"published"}
|
|
]'
|
|
mock_start
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == "http://localhost:18080/test-owner/test-repo/main/abc123de/unit-tests/" ]]
|
|
}
|
|
|
|
@test "publish with suite subpath" {
|
|
mkdir -p "sub/suite"
|
|
echo "sub" > "sub/suite/result.html"
|
|
mock_set_sequence '[
|
|
{"code":200,"body":"published"}
|
|
]'
|
|
mock_start
|
|
run bash scripts/publish-git-pages.sh "sub/suite"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == "http://localhost:18080/test-owner/test-repo/main/abc123de/sub/suite/" ]]
|
|
}
|
|
|
|
@test "git-pages returns HTTP 500 → exit 1" {
|
|
mock_set_sequence '[
|
|
{"code":500,"body":"internal error"}
|
|
]'
|
|
mock_start
|
|
run bash scripts/publish-git-pages.sh "unit-tests"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"500"* ]]
|
|
}
|