fix: tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 7s
CI Workflow / CI (pull_request) Failing after 27m26s
CI Workflow / Code coverage report (pull_request) Has been skipped
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 34m1s

This commit is contained in:
Marcel S. Henselin 2026-02-13 11:26:47 +01:00
parent 10af1dbbba
commit 57758e1efc
6 changed files with 172 additions and 39 deletions

View file

@ -132,7 +132,7 @@ func TestMapFields(t *testing.T) {
func TestMapResourceFields(t *testing.T) {
type given struct {
source *postgresflexalpha.ListDatabase
source *postgresflexalpha.GetDatabaseResponse
model *resourceModel
}
type expected struct {
@ -148,10 +148,10 @@ func TestMapResourceFields(t *testing.T) {
{
name: "should map fields correctly",
given: given{
source: &postgresflexalpha.ListDatabase{
source: &postgresflexalpha.GetDatabaseResponse{
Id: utils.Ptr(int64(1)),
Name: utils.Ptr("my-db"),
Owner: utils.Ptr("\"my-owner\""),
Owner: utils.Ptr("my-owner"),
},
model: &resourceModel{},
},

View file

@ -21,6 +21,38 @@ import (
const pfx = "stackitprivatepreview_postgresflexalpha"
var createdInstances []string
func init() {
sweeperName := fmt.Sprintf("%s_%s", pfx, "sweeper")
resource.AddTestSweepers(sweeperName, &resource.Sweeper{
Name: sweeperName,
F: func(region string) error {
//client, err := sharedClientForRegion(region)
//if err != nil {
// return fmt.Errorf("Error getting client: %s", err)
//}
//conn := client.(*ExampleClient)
//
//instances, err := conn.DescribeComputeInstances()
//if err != nil {
// return fmt.Errorf("Error getting instances: %s", err)
//}
//for _, instance := range instances {
// if strings.HasPrefix(instance.Name, "test-acc") {
// err := conn.DestroyInstance(instance.ID)
//
// if err != nil {
// log.Printf("Error destroying %s during sweep: %s", instance.Name, err)
// }
// }
//}
return nil
},
})
}
func TestInstanceResourceSchema(t *testing.T) {
t.Parallel()
@ -58,13 +90,6 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
//var (
// validFlavor = "2.4"
// kekKeyRingId = ""
// kekKeyVersion = ""
// kekKeySA = ""
//)
func testAccPreCheck(t *testing.T) {
if _, ok := os.LookupEnv("TF_ACC_PROJECT_ID"); !ok {
t.Fatalf("could not find env var TF_ACC_PROJECT_ID")
@ -151,7 +176,6 @@ func getExample() resData {
func TestAccInstance(t *testing.T) {
exData := getExample()
t.Logf(" ... working on instance %s", exData.TfName)
resName := fmt.Sprintf(
"stackitprivatepreview_postgresflexalpha_instance.%s",
@ -164,8 +188,11 @@ func TestAccInstance(t *testing.T) {
updSizeData := exData
updSizeData.Size = 25
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", exData.TfName)
},
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
@ -215,7 +242,6 @@ func TestAccInstance(t *testing.T) {
func TestAccInstanceWithUsers(t *testing.T) {
data := getExample()
t.Logf(" ... working on instance %s", data.TfName)
userName := "testUser"
data.Users = []User{
@ -226,8 +252,11 @@ func TestAccInstanceWithUsers(t *testing.T) {
},
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
},
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
@ -249,7 +278,6 @@ func TestAccInstanceWithUsers(t *testing.T) {
func TestAccInstanceWithDatabases(t *testing.T) {
data := getExample()
t.Logf(" ... working on instance %s", data.TfName)
dbName := "testDb"
userName := "testUser"
@ -284,8 +312,11 @@ func TestAccInstanceWithDatabases(t *testing.T) {
dbName,
)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
},
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
@ -367,7 +398,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
// ProjectID: project_id,
// Name: "testRes",
// }
// resource.Test(t, resource.TestCase{
// resource.ParallelTest(t, resource.TestCase{
// ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
// Steps: []resource.TestStep{
// {
@ -510,7 +541,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
//}
//
//func TestAccPostgresFlexFlexResource(t *testing.T) {
// resource.Test(
// resource.ParallelTest(
// t, resource.TestCase{
// ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
// CheckDestroy: testAccCheckPostgresFlexDestroy,

View file

@ -452,7 +452,7 @@ func (r *userResource) Update(
ctx,
&resp.Diagnostics,
"read user",
fmt.Sprintf("Instance creation waiting: %v", err),
fmt.Sprintf("user update waiting: %v", err),
)
return
}
@ -461,8 +461,8 @@ func (r *userResource) Update(
core.LogAndAddError(
ctx,
&resp.Diagnostics,
"read user",
"Instance creation waiting: returned id is nil or wrong",
"update user",
"User creation waiting: returned id is nil or wrong",
)
return
}