|
88 | 88 |
|
89 | 89 | //go:embed testdata/resource-server-max-server-attachments.tf
|
90 | 90 | resourceServerMaxAttachmentConfig string
|
| 91 | + |
| 92 | + //go:embed testdata/datasource-machinetype.tf |
| 93 | + dataSourceMachineTypeConfig string |
91 | 94 | )
|
92 | 95 |
|
93 | 96 | const (
|
@@ -487,6 +490,10 @@ var testConfigKeyPairMaxUpdated = func() config.Variables {
|
487 | 490 | return updatedConfig
|
488 | 491 | }()
|
489 | 492 |
|
| 493 | +var testConfigMachineTypeVars = config.Variables{ |
| 494 | + "project_id": config.StringVariable(testutil.ProjectId), |
| 495 | +} |
| 496 | + |
490 | 497 | // if no local file is provided the test should create a default file and work with this instead of failing
|
491 | 498 | var localFileForIaasImage os.File
|
492 | 499 |
|
@@ -4054,6 +4061,47 @@ func TestAccProject(t *testing.T) {
|
4054 | 4061 | })
|
4055 | 4062 | }
|
4056 | 4063 |
|
| 4064 | +func TestAccMachineType(t *testing.T) { |
| 4065 | + t.Logf("TestAccMachineType projectid: %s", testutil.ConvertConfigVariable(testConfigMachineTypeVars["project_id"])) |
| 4066 | + resource.ParallelTest(t, resource.TestCase{ |
| 4067 | + ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories, |
| 4068 | + Steps: []resource.TestStep{ |
| 4069 | + { |
| 4070 | + ConfigVariables: testConfigMachineTypeVars, |
| 4071 | + Config: fmt.Sprintf("%s\n%s", dataSourceMachineTypeConfig, testutil.IaaSProviderConfigWithBetaResourcesEnabled()), |
| 4072 | + Check: resource.ComposeTestCheckFunc( |
| 4073 | + resource.TestCheckResourceAttr("data.stackit_machine_type.two_vcpus_filter", "project_id", testutil.ConvertConfigVariable(testConfigMachineTypeVars["project_id"])), |
| 4074 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "id"), |
| 4075 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "name"), |
| 4076 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "vcpus"), |
| 4077 | + resource.TestCheckResourceAttr("data.stackit_machine_type.two_vcpus_filter", "vcpus", "2"), |
| 4078 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "ram"), |
| 4079 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "disk"), |
| 4080 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "description"), |
| 4081 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.two_vcpus_filter", "extra_specs.cpu"), |
| 4082 | + |
| 4083 | + resource.TestCheckResourceAttr("data.stackit_machine_type.filter_sorted_ascending_false", "project_id", testutil.ConvertConfigVariable(testConfigMachineTypeVars["project_id"])), |
| 4084 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "id"), |
| 4085 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "name"), |
| 4086 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "vcpus"), |
| 4087 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "ram"), |
| 4088 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "disk"), |
| 4089 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "description"), |
| 4090 | + resource.TestCheckResourceAttrSet("data.stackit_machine_type.filter_sorted_ascending_false", "extra_specs.cpu"), |
| 4091 | + |
| 4092 | + resource.TestCheckResourceAttr("data.stackit_machine_type.no_match", "project_id", testutil.ConvertConfigVariable(testConfigMachineTypeVars["project_id"])), |
| 4093 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "description"), |
| 4094 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "disk"), |
| 4095 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "extra_specs"), |
| 4096 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "id"), |
| 4097 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "name"), |
| 4098 | + resource.TestCheckNoResourceAttr("data.stackit_machine_type.no_match", "ram"), |
| 4099 | + ), |
| 4100 | + }, |
| 4101 | + }, |
| 4102 | + }) |
| 4103 | +} |
| 4104 | + |
4057 | 4105 | func testAccCheckDestroy(s *terraform.State) error {
|
4058 | 4106 | checkFunctions := []func(s *terraform.State) error{
|
4059 | 4107 | testAccCheckNetworkV1Destroy,
|
|
0 commit comments