feat: add_testing #45

Merged
marcel.henselin merged 7 commits from feat/add_testing into alpha 2026-02-10 16:46:21 +00:00
Showing only changes of commit 05ae461817 - Show all commits

View file

@ -76,12 +76,12 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
var (
validFlavor = "2.4"
kekKeyRingId = ""
kekKeyVersion = ""
kekKeySA = ""
)
//var (
// validFlavor = "2.4"
// kekKeyRingId = ""
// kekKeyVersion = ""
// kekKeySA = ""
//)
func testAccPreCheck(t *testing.T) {
// TODO: if needed ...
@ -202,63 +202,63 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "test" {
)
}
func testAccResourceEncryptionExampleConfig(data resData) string {
return fmt.Sprintf(`
//func testAccResourceEncryptionExampleConfig(data resData) string {
// return fmt.Sprintf(`
//
//%[1]s
//
//resource "stackitprivatepreview_postgresflexalpha_instance" "test" {
// project_id = %[2]q
// name = %[3]q
// backup_schedule = "0 0 * * *"
// retention_days = 45
// flavor_id = "2.1"
// replicas = 1
// storage = {
// performance_class = "premium-perf2-stackit"
// size = 10
// }
// encryption = {
// kek_key_id = "key01"
// kek_key_ring_id = "key_ring_01"
// kek_key_version = 1
// service_account = "service@account.email"
// }
// network = {
// acl = ["0.0.0.0/0"]
// access_scope = "PUBLIC"
// }
// version = 14
//}
//
//`,
// testutil.PostgresFlexProviderConfig(data.ServiceAccountFilePath),
// data.ProjectID,
// data.Name,
// )
//}
%[1]s
resource "stackitprivatepreview_postgresflexalpha_instance" "test" {
project_id = %[2]q
name = %[3]q
backup_schedule = "0 0 * * *"
retention_days = 45
flavor_id = "2.1"
replicas = 1
storage = {
performance_class = "premium-perf2-stackit"
size = 10
}
encryption = {
kek_key_id = "key01"
kek_key_ring_id = "key_ring_01"
kek_key_version = 1
service_account = "service@account.email"
}
network = {
acl = ["0.0.0.0/0"]
access_scope = "PUBLIC"
}
version = 14
}
`,
testutil.PostgresFlexProviderConfig(data.ServiceAccountFilePath),
data.ProjectID,
data.Name,
)
}
func testCheckResourceExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmt.Errorf("resource not found: %s", resourceName)
}
if rs.Primary.ID == "" {
return fmt.Errorf("resource ID not set")
}
// Verify resource exists in the API
//client := testAccProvider.Meta().(*APIClient)
//_, err := client.GetResource(rs.Primary.ID)
//if err != nil {
// return fmt.Errorf("error fetching resource: %w", err)
//}
return nil
}
}
//func testCheckResourceExists(resourceName string) resource.TestCheckFunc {
// return func(s *terraform.State) error {
// rs, ok := s.RootModule().Resources[resourceName]
// if !ok {
// return fmt.Errorf("resource not found: %s", resourceName)
// }
//
// if rs.Primary.ID == "" {
// return fmt.Errorf("resource ID not set")
// }
//
// // Verify resource exists in the API
// //client := testAccProvider.Meta().(*APIClient)
// //_, err := client.GetResource(rs.Primary.ID)
// //if err != nil {
// // return fmt.Errorf("error fetching resource: %w", err)
// //}
//
// return nil
// }
//}
func setupMockServer() *httptest.Server {
mux := http.NewServeMux()