From 2d90050e688f32d412d442b586d040b4bbc09905 Mon Sep 17 00:00:00 2001 From: philthoennissen Date: Tue, 22 Oct 2024 15:35:15 +0200 Subject: [PATCH] Add tests for 'allow_extension_operations' Signed-off-by: philthoennissen --- tests/local/input_vm_extension.tftest.hcl | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/local/input_vm_extension.tftest.hcl diff --git a/tests/local/input_vm_extension.tftest.hcl b/tests/local/input_vm_extension.tftest.hcl new file mode 100644 index 0000000..bdd4a54 --- /dev/null +++ b/tests/local/input_vm_extension.tftest.hcl @@ -0,0 +1,31 @@ +mock_provider "azapi" { source = "tests/local/mocks" } +mock_provider "azurerm" { source = "tests/local/mocks" } +mock_provider "random" { source = "tests/local/mocks" } +mock_provider "tls" { source = "tests/local/mocks" } + +run "no_extension_should_be_created" { + command = plan + + variables { + allow_extension_operations = false + extensions = [] + } + + assert { + condition = length(azurerm_virtual_machine_extension.this) == 0 + error_message = "It is not possible to install extension with 'allow_extension_operations = false'. The azurerm_virtual_machine_extension.this length is ${length(azurerm_virtual_machine_extension.this)}." + } +} + +run "no_extension_should_be_created_2" { + command = plan + + variables { + allow_extension_operations = false + } + + assert { + condition = length(azurerm_virtual_machine_extension.this) == 0 + error_message = "It is not possible to install extension with 'allow_extension_operations = false'. The azurerm_virtual_machine_extension.this length is ${length(azurerm_virtual_machine_extension.this)}." + } +}