|
35 | 35 | //go:embed testdata/resource-security-group-max.tf
|
36 | 36 | resourceSecurityGroupMaxConfig string
|
37 | 37 |
|
| 38 | + //go:embed testdata/datasource-image-v2-variants.tf |
| 39 | + dataSourceImageVariants string |
| 40 | + |
38 | 41 | //go:embed testdata/resource-image-min.tf
|
39 | 42 | resourceImageMinConfig string
|
40 | 43 |
|
@@ -4029,6 +4032,133 @@ func TestAccImageMax(t *testing.T) {
|
4029 | 4032 | })
|
4030 | 4033 | }
|
4031 | 4034 |
|
| 4035 | +func TestAccImageV2DatasourceSearchVariants(t *testing.T) { |
| 4036 | + t.Log("TestDataSource Image V2 Variants") |
| 4037 | + resource.ParallelTest(t, resource.TestCase{ |
| 4038 | + ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories, |
| 4039 | + Steps: []resource.TestStep{ |
| 4040 | + // Creation |
| 4041 | + { |
| 4042 | + ConfigVariables: config.Variables{"project_id": config.StringVariable(testutil.ProjectId)}, |
| 4043 | + Config: fmt.Sprintf("%s\n%s", dataSourceImageVariants, testutil.IaaSProviderConfigWithBetaResourcesEnabled()), |
| 4044 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 4045 | + resource.TestCheckResourceAttr("data.stackit_image_v2.name_match_ubuntu_22_04", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4046 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "image_id"), |
| 4047 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "name"), |
| 4048 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "min_disk_size"), |
| 4049 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "min_ram"), |
| 4050 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "protected"), |
| 4051 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "scope"), |
| 4052 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "checksum.algorithm"), |
| 4053 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_match_ubuntu_22_04", "checksum.digest"), |
| 4054 | + |
| 4055 | + resource.TestCheckResourceAttr("data.stackit_image_v2.ubuntu_by_image_id", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4056 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "image_id"), |
| 4057 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "name"), |
| 4058 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "min_disk_size"), |
| 4059 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "min_ram"), |
| 4060 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "protected"), |
| 4061 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "scope"), |
| 4062 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "checksum.algorithm"), |
| 4063 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_by_image_id", "checksum.digest"), |
| 4064 | + |
| 4065 | + resource.TestCheckResourceAttr("data.stackit_image_v2.regex_match_ubuntu_22_04", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4066 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "image_id"), |
| 4067 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "name"), |
| 4068 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "min_disk_size"), |
| 4069 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "min_ram"), |
| 4070 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "protected"), |
| 4071 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "scope"), |
| 4072 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "checksum.algorithm"), |
| 4073 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.regex_match_ubuntu_22_04", "checksum.digest"), |
| 4074 | + |
| 4075 | + resource.TestCheckResourceAttr("data.stackit_image_v2.filter_debian_11", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4076 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "image_id"), |
| 4077 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "name"), |
| 4078 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "min_disk_size"), |
| 4079 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "min_ram"), |
| 4080 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "protected"), |
| 4081 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "scope"), |
| 4082 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "checksum.algorithm"), |
| 4083 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_debian_11", "checksum.digest"), |
| 4084 | + |
| 4085 | + resource.TestCheckResourceAttr("data.stackit_image_v2.filter_uefi_ubuntu", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4086 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "image_id"), |
| 4087 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "name"), |
| 4088 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "min_disk_size"), |
| 4089 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "min_ram"), |
| 4090 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "protected"), |
| 4091 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "scope"), |
| 4092 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "checksum.algorithm"), |
| 4093 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.filter_uefi_ubuntu", "checksum.digest"), |
| 4094 | + |
| 4095 | + resource.TestCheckResourceAttr("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4096 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "image_id"), |
| 4097 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "name"), |
| 4098 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "min_disk_size"), |
| 4099 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "min_ram"), |
| 4100 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "protected"), |
| 4101 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "scope"), |
| 4102 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "checksum.algorithm"), |
| 4103 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_regex_and_filter_rhel_9_1", "checksum.digest"), |
| 4104 | + |
| 4105 | + resource.TestCheckResourceAttr("data.stackit_image_v2.name_windows_2022_standard", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4106 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "image_id"), |
| 4107 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "name"), |
| 4108 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "min_disk_size"), |
| 4109 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "min_ram"), |
| 4110 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "protected"), |
| 4111 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "scope"), |
| 4112 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "checksum.algorithm"), |
| 4113 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.name_windows_2022_standard", "checksum.digest"), |
| 4114 | + |
| 4115 | + resource.TestCheckResourceAttr("data.stackit_image_v2.ubuntu_arm64_latest", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4116 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "image_id"), |
| 4117 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "name"), |
| 4118 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "min_disk_size"), |
| 4119 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "min_ram"), |
| 4120 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "protected"), |
| 4121 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "scope"), |
| 4122 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "checksum.algorithm"), |
| 4123 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_latest", "checksum.digest"), |
| 4124 | + |
| 4125 | + resource.TestCheckResourceAttr("data.stackit_image_v2.ubuntu_arm64_oldest", "project_id", testutil.ConvertConfigVariable(testConfigImageVarsMax["project_id"])), |
| 4126 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "image_id"), |
| 4127 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "name"), |
| 4128 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "min_disk_size"), |
| 4129 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "min_ram"), |
| 4130 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "protected"), |
| 4131 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "scope"), |
| 4132 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "checksum.algorithm"), |
| 4133 | + resource.TestCheckResourceAttrSet("data.stackit_image_v2.ubuntu_arm64_oldest", "checksum.digest"), |
| 4134 | + |
| 4135 | + // e2e test that ascending sort is working |
| 4136 | + func(s *terraform.State) error { |
| 4137 | + latest := s.RootModule().Resources["data.stackit_image_v2.ubuntu_arm64_latest"] |
| 4138 | + oldest := s.RootModule().Resources["data.stackit_image_v2.ubuntu_arm64_oldest"] |
| 4139 | + |
| 4140 | + if latest == nil { |
| 4141 | + return fmt.Errorf("datasource 'data.stackit_image_v2.ubuntu_arm64_latest' not found") |
| 4142 | + } |
| 4143 | + if oldest == nil { |
| 4144 | + return fmt.Errorf("datasource 'data.stackit_image_v2.ubuntu_arm64_oldest' not found") |
| 4145 | + } |
| 4146 | + |
| 4147 | + nameLatest := latest.Primary.Attributes["name"] |
| 4148 | + nameOldest := oldest.Primary.Attributes["name"] |
| 4149 | + |
| 4150 | + if nameLatest == nameOldest { |
| 4151 | + return fmt.Errorf("expected image names to differ, but both are %q", nameLatest) |
| 4152 | + } |
| 4153 | + |
| 4154 | + return nil |
| 4155 | + }, |
| 4156 | + ), |
| 4157 | + }, |
| 4158 | + }, |
| 4159 | + }) |
| 4160 | +} |
| 4161 | + |
4032 | 4162 | func TestAccProject(t *testing.T) {
|
4033 | 4163 | projectId := testutil.ProjectId
|
4034 | 4164 | resource.ParallelTest(t, resource.TestCase{
|
|
0 commit comments