Patrick de Ruiter cfbe6cbdc4
Some checks failed
Code Quality & Security Scan / TFLint (push) Successful in 24s
Code Quality & Security Scan / Terraform Destroy (push) Has been skipped
Code Quality & Security Scan / Tfsec Security Scan (push) Successful in 29s
Code Quality & Security Scan / Checkov Security Scan (push) Successful in 44s
Code Quality & Security Scan / Terraform Tests (push) Failing after 35s
Code Quality & Security Scan / SonarQube Trigger (push) Has been skipped
Code Quality & Security Scan / Terraform Init (push) Has been skipped
Code Quality & Security Scan / Terraform Apply (push) Has been skipped
Add comprehensive Terraform testing framework
- Implemented 21 test cases across 3 test suites:
  * resource_groups.tftest.hcl (7 tests): Default behavior and validation
  * custom_configuration.tftest.hcl (6 tests): Custom configurations
  * variable_validation.tftest.hcl (8 tests): Input validation and edge cases

- Updated CI/CD pipeline (.gitea/workflows/sonarqube.yaml):
  * Added terraform-test job with format check and test execution
  * Generates and uploads test reports (30-day retention)
  * Runs after security scanning, before deployment

- Added comprehensive documentation:
  * TESTING.md: Complete testing guide with best practices
  * TEST_SUMMARY.md: Implementation summary and statistics
  * TESTING_QUICK_START.md: Quick reference for developers
  * TESTING_WORKFLOW.md: Visual workflow diagrams

- Updated existing documentation:
  * README.md: Added testing section with examples
  * CLAUDE.md: Added test commands to workflow

- Test coverage includes:
  * Resource creation and configuration validation
  * Tag category and tag management
  * Variable validation and defaults
  * Custom configurations and overrides
  * Edge cases and error handling
  * Output generation verification

Tests use mock credentials for infrastructure-independent execution.
Requires Terraform >= 1.6.0 for native testing framework.
2025-11-09 00:37:45 +01:00

36 lines
852 B
HCL

# Mock setup for testing
# This configuration provides mock data sources for testing without actual vSphere access
terraform {
required_version = ">= 1.6.0"
required_providers {
vsphere = {
source = "hashicorp/vsphere"
version = "~> 2.10"
}
}
}
# Mock datacenter (for testing, we'll use override files)
data "vsphere_datacenter" "datacenter" {
name = var.datacenter
}
# Mock compute cluster (for testing, we'll use override files)
data "vsphere_compute_cluster" "cluster" {
name = var.cluster_name
datacenter_id = data.vsphere_datacenter.datacenter.id
}
variable "datacenter" {
description = "Mock datacenter for testing"
type = string
default = "test-dc"
}
variable "cluster_name" {
description = "Mock cluster name for testing"
type = string
default = "test-cluster"
}