# Testing Guide - Proxmox Provider This document provides guidance for testing the Crossplane Proxmox provider. ## Unit Tests ### Running Unit Tests ```bash # Run all unit tests go test ./pkg/... # Run tests for specific package go test ./pkg/utils/... go test ./pkg/proxmox/... go test ./pkg/controller/virtualmachine/... # Run with coverage go test -cover ./pkg/... # Generate coverage report go test -coverprofile=coverage.out ./pkg/... go tool cover -html=coverage.out ``` ### Test Files - `pkg/utils/parsing_test.go` - Parsing utility tests - `pkg/utils/validation_test.go` - Validation function tests - `pkg/proxmox/networks_test.go` - Network API tests - `pkg/proxmox/client_tenant_test.go` - Tenant tag format tests - `pkg/controller/virtualmachine/errors_test.go` - Error categorization tests ## Integration Tests Integration tests require a Proxmox test environment. ### Prerequisites 1. Proxmox VE cluster with API access 2. Valid API credentials 3. Test node with available resources 4. Test storage pools 5. Network bridges configured ### Running Integration Tests ```bash # Run integration tests go test -tags=integration ./pkg/controller/virtualmachine/... # Skip integration tests (run unit tests only) go test -short ./pkg/... ``` ### Integration Test Scenarios 1. **VM Creation with Template Cloning** - Requires: Template VM (VMID 100-999999999) - Tests: Template clone functionality 2. **VM Creation with Cloud Image Import** - Requires: Cloud image in storage, importdisk API support - Tests: Image import functionality 3. **VM Creation with Pre-imported Images** - Requires: Pre-imported image in storage - Tests: Image reference functionality 4. **Multi-Site Deployment** - Requires: Multiple Proxmox sites configured - Tests: Site selection and validation 5. **Network Bridge Validation** - Requires: Network bridges on test nodes - Tests: Network existence validation 6. **Error Recovery** - Tests: Retry logic and error handling 7. **Cloud-init Configuration** - Requires: Cloud-init support - Tests: UserData writing and configuration ## Manual Testing ### Prerequisites - Kubernetes cluster with Crossplane installed - Proxmox provider deployed - ProviderConfig configured - Valid credentials ### Test Scenarios #### 1. Tenant Tags ```bash # Create VM with tenant ID kubectl apply -f - <80% code coverage