chore: work save
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m57s
CI Workflow / CI run tests (pull_request) Failing after 5m5s
CI Workflow / CI run build and linting (pull_request) Failing after 4m50s
CI Workflow / Code coverage report (pull_request) Has been skipped

This commit is contained in:
Marcel S. Henselin 2026-03-05 15:11:15 +01:00
parent 411e99739a
commit d6d3a795bb
118 changed files with 3101 additions and 18065 deletions

View file

@ -7,7 +7,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
)
type mockRequest struct {
@ -37,28 +37,28 @@ func (m *mockDBClient) ListDatabasesRequest(
}
func TestGetDatabase(t *testing.T) {
mockResp := func(page int64) (*postgresflex.ListDatabasesResponse, error) {
mockResp := func(page int32) (*postgresflex.ListDatabasesResponse, error) {
if page == 1 {
return &postgresflex.ListDatabasesResponse{
Databases: &[]postgresflex.ListDatabase{
{Id: utils.Ptr(int64(1)), Name: utils.Ptr("first")},
{Id: utils.Ptr(int64(2)), Name: utils.Ptr("second")},
{Id: utils.Ptr(int32(1)), Name: utils.Ptr("first")},
{Id: utils.Ptr(int32(2)), Name: utils.Ptr("second")},
},
Pagination: &postgresflex.Pagination{
Page: utils.Ptr(int64(1)),
TotalPages: utils.Ptr(int64(2)),
Size: utils.Ptr(int64(3)),
Page: utils.Ptr(int32(1)),
TotalPages: utils.Ptr(int32(2)),
Size: utils.Ptr(int32(3)),
},
}, nil
}
if page == 2 {
return &postgresflex.ListDatabasesResponse{
Databases: &[]postgresflex.ListDatabase{{Id: utils.Ptr(int64(3)), Name: utils.Ptr("three")}},
Databases: &[]postgresflex.ListDatabase{{Id: utils.Ptr(int32(3)), Name: utils.Ptr("three")}},
Pagination: &postgresflex.Pagination{
Page: utils.Ptr(int64(2)),
TotalPages: utils.Ptr(int64(2)),
Size: utils.Ptr(int64(3)),
Page: utils.Ptr(int32(2)),
TotalPages: utils.Ptr(int32(2)),
Size: utils.Ptr(int32(3)),
},
}, nil
}
@ -66,9 +66,9 @@ func TestGetDatabase(t *testing.T) {
return &postgresflex.ListDatabasesResponse{
Databases: &[]postgresflex.ListDatabase{},
Pagination: &postgresflex.Pagination{
Page: utils.Ptr(int64(3)),
TotalPages: utils.Ptr(int64(2)),
Size: utils.Ptr(int64(3)),
Page: utils.Ptr(int32(3)),
TotalPages: utils.Ptr(int32(2)),
Size: utils.Ptr(int32(3)),
},
}, nil
}
@ -80,7 +80,7 @@ func TestGetDatabase(t *testing.T) {
instanceId string
wantErr bool
wantDbName string
wantDbId int64
wantDbId int32
}{
{
description: "Success - Found by name on first page",
@ -133,7 +133,7 @@ func TestGetDatabase(t *testing.T) {
for _, tt := range tests {
t.Run(
tt.description, func(t *testing.T) {
var currentPage int64
var currentPage int32
client := &mockDBClient{
executeRequest: func() postgresflex.ApiListDatabasesRequestRequest {
return &mockRequest{