Files
OpenTofuPlayground/proxmox/tests/proxmox_validation.tftest.hcl
Lutz Finsterle b2a3e00452
Some checks failed
Deploy / Update Proxmox Dev VMs / Detect changed Proxmox tfvars (push) Successful in 26s
Test / Static Analysis (push) Failing after 25s
Test / Unit Tests — Docker Stack (push) Has been skipped
Test / Unit Tests — K8s Stack (push) Has been skipped
Deploy / Update Proxmox Dev VMs / Provision ${{ matrix.tfvars }} (push) Failing after 32s
Deploy / Update Proxmox Dev VMs / Destroy ${{ matrix.tfvars }} (push) Has been skipped
Test / Integration Test — K8s (k3d) (push) Has been skipped
New Function: DEV VM
2026-03-20 10:06:05 +01:00

102 lines
2.9 KiB
HCL

# Unit tests for the Proxmox stack using mock providers.
# No real Proxmox or TLS infrastructure is required.
mock_provider "proxmox" {}
mock_provider "tls" {}
# ─── Shared variable defaults ─────────────────────────────────────────────────
variables {
proxmox_endpoint = "https://proxmox.example.com:8006/"
proxmox_api_token = "test@pam!ci=00000000-0000-0000-0000-000000000000"
proxmox_node = "pve"
template_vm_id = 9000
storage_pool = "local-lvm"
vm_role = "docker"
}
# ─── Role: docker ─────────────────────────────────────────────────────────────
run "docker_vm_role_is_propagated" {
command = plan
assert {
condition = module.dev_vm.vm_role == "docker"
error_message = "vm_role output should equal the input 'docker'."
}
}
run "docker_vm_key_generated_when_no_public_key_provided" {
command = plan
variables {
ssh_public_key = ""
}
assert {
condition = module.dev_vm.key_was_generated == true
error_message = "key_was_generated should be true when ssh_public_key is empty."
}
}
run "docker_vm_key_not_generated_when_public_key_provided" {
command = plan
variables {
ssh_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyForTesting developer@example.com"
}
assert {
condition = module.dev_vm.key_was_generated == false
error_message = "key_was_generated should be false when ssh_public_key is provided."
}
}
# ─── Role: k3s ────────────────────────────────────────────────────────────────
run "k3s_vm_role_is_propagated" {
command = plan
variables {
vm_role = "k3s"
}
assert {
condition = module.dev_vm.vm_role == "k3s"
error_message = "vm_role output should equal the input 'k3s'."
}
}
# ─── Variable validation ──────────────────────────────────────────────────────
run "reject_invalid_vm_role" {
command = plan
variables {
vm_role = "nomad"
}
expect_failures = [var.vm_role]
}
run "reject_another_invalid_role" {
command = plan
variables {
vm_role = "both"
}
expect_failures = [var.vm_role]
}
# ─── Sizing defaults are applied ──────────────────────────────────────────────
run "default_cloud_init_user" {
command = plan
assert {
condition = module.dev_vm.cloud_init_user == "developer"
error_message = "Default cloud_init_user should be 'developer'."
}
}