This repository has been archived on 2026-11-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
terraform-git/modules/github_org/tests/github_org.tftest.hcl
T
unkin-agent a99c8f04fd
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
archive github repos on destroy, reject unknown rulesets
2026-11-10 00:05:34 +11:00

80 lines
2.0 KiB
HCL

mock_provider "github" {
mock_resource "github_team" {
defaults = { slug = "maintainers-slug" }
}
}
variables {
owner = "IUCLabs"
team = {
maintainers = { name = "maintainers", maintainers = ["alice"], members = ["bob"] }
}
ruleset = {
default = { name = "default", rules = { deletion = true, pull_request = {} } }
}
}
run "public_repo_with_ruleset" {
command = plan
variables {
repository = {
".github" = { name = ".github", private = false, rulesets = ["default"], maintainers = ["@maintainers", "carol"], codeowners = ["carol", "dave"] }
}
}
assert {
condition = github_repository_file.codeowners[".github"].content == "* @IUCLabs/maintainers-slug @carol\n"
error_message = "CODEOWNERS must list maintainers, teams by owner-qualified slug"
}
assert {
condition = local.repository_access[".github"] == { "@maintainers" = "maintain", carol = "maintain", dave = "push" }
error_message = "maintainers get maintain (winning over codeowners), codeowners get push"
}
assert {
condition = length(github_repository_ruleset.this) == 1 && length(github_team_membership.this) == 2
error_message = "expected one ruleset and two team memberships"
}
}
run "no_codeowners_without_auto_init" {
command = plan
variables {
repository = {
empty = { name = "empty", private = false, auto_init = false, maintainers = ["@maintainers"] }
}
}
assert {
condition = length(github_repository_file.codeowners) == 0
error_message = "CODEOWNERS needs an initialised default branch"
}
}
run "private_repo_with_ruleset_rejected" {
command = plan
variables {
repository = {
secret = { name = "secret", private = true, rulesets = ["default"] }
}
}
expect_failures = [var.repository]
}
run "unknown_ruleset_rejected" {
command = plan
variables {
repository = {
public = { name = "public", private = false, rulesets = ["missing"] }
}
}
expect_failures = [var.repository]
}