diff --git a/services/postgresflex/CHANGELOG.md b/services/postgresflex/CHANGELOG.md index a9d21ffd1..9d1e8f202 100644 --- a/services/postgresflex/CHANGELOG.md +++ b/services/postgresflex/CHANGELOG.md @@ -1,9 +1,3 @@ -## v1.12.0 -- **Breaking Change:** The `v3api` replaces the `v2api`. -- `v3api`: **New:** New package which can be used for communication with the postgresflex v3 API -- `v2api`: **Deprecated:** `v2api` is deprecated, use instead `v3api` -- `v3beta1api`: **Deprecated:** `v3beta1api` is deprecated, use instead `v3api` - ## v1.11.0 - `v3beta1api`: **New:** New package which can be used for communication with the PostgreSQL Flex v3beta1 API - `v1api`: **Deprecated:** `v1api` is deprecated, use instead `v2api` diff --git a/services/postgresflex/VERSION b/services/postgresflex/VERSION index 13a15bd96..285cea5d1 100644 --- a/services/postgresflex/VERSION +++ b/services/postgresflex/VERSION @@ -1 +1 @@ -v1.12.0 \ No newline at end of file +v1.11.0 \ No newline at end of file diff --git a/services/postgresflex/oas_commit b/services/postgresflex/oas_commit index 5be2ed399..1538b64bb 100644 --- a/services/postgresflex/oas_commit +++ b/services/postgresflex/oas_commit @@ -1 +1 @@ -3743740fd64567e45d0d0136ba9002f4f3c5e495 +d5bd75f47f4b364fa6f71663efb4ba41ec703ac8 diff --git a/services/postgresflex/v3api/wait/wait.go b/services/postgresflex/v3api/wait/wait.go deleted file mode 100644 index f85cc7771..000000000 --- a/services/postgresflex/v3api/wait/wait.go +++ /dev/null @@ -1,114 +0,0 @@ -package wait - -import ( - "context" - "errors" - "net/http" - "time" - - "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/core/wait" - postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3api" -) - -// createOrUpdateInstanceWaitHandler will wait for instance creation -func createOrUpdateInstanceWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - waitConfig := wait.WaiterHelper[postgresflex.GetInstanceResponse, postgresflex.State]{ - FetchInstance: client.GetInstance(ctx, projectId, region, instanceId).Execute, - GetState: func(response *postgresflex.GetInstanceResponse) (postgresflex.State, error) { - if response == nil { - return "", errors.New("empty response") - } - if response.State == "" { - return "", errors.New("state is missing") - } - return response.State, nil - }, - ActiveState: []postgresflex.State{postgresflex.STATE_READY}, - ErrorState: []postgresflex.State{ - postgresflex.STATE_FAILURE, - postgresflex.STATE_UNKNOWN, - postgresflex.STATE_TERMINATING, - }, - } - - handler := wait.New(waitConfig.Wait()) - handler.SetTimeout(45 * time.Minute) - return handler -} - -// CreateInstanceWaitHandler will wait for instance creation -func CreateInstanceWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - return createOrUpdateInstanceWaitHandler(ctx, client, projectId, region, instanceId).SetSleepBeforeWait(15 * time.Second) -} - -// PartialUpdateInstanceWaitHandler will wait for instance update -func PartialUpdateInstanceWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - return createOrUpdateInstanceWaitHandler(ctx, client, projectId, region, instanceId) -} - -// CloneInstanceWaitHandler will wait for instance cloning -func CloneInstanceWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - return createOrUpdateInstanceWaitHandler(ctx, client, projectId, region, instanceId) -} - -// DeleteInstanceWaitHandler will wait for instance deletion -func DeleteInstanceWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - waitConfig := wait.WaiterHelper[postgresflex.GetInstanceResponse, postgresflex.State]{ - FetchInstance: client.GetInstance(ctx, projectId, region, instanceId).Execute, - GetState: func(response *postgresflex.GetInstanceResponse) (postgresflex.State, error) { - if response == nil { - return "", errors.New("empty response") - } - if response.State == "" { - return "", errors.New("status is missing in response") - } - return response.State, nil - }, - ErrorState: []postgresflex.State{postgresflex.STATE_FAILURE}, - DeleteHttpErrorStatusCodes: []int{http.StatusNotFound}, - } - handler := wait.New(waitConfig.Wait()) - handler.SetTimeout(15 * time.Minute) - return handler -} - -// CreateUserWaitHandler will wait for user creation -func CreateUserWaitHandler(ctx context.Context, client postgresflex.DefaultAPI, projectId, region, instanceId string, userId int64) *wait.AsyncActionHandler[postgresflex.GetUserResponse] { - waitConfig := wait.WaiterHelper[postgresflex.GetUserResponse, string]{ - FetchInstance: client.GetUser(ctx, projectId, region, instanceId, userId).Execute, - GetState: func(response *postgresflex.GetUserResponse) (string, error) { - if response == nil { - return "", errors.New("empty response") - } - return response.State, nil - }, - ActiveState: []string{"PROCESSED"}, - ErrorState: []string{}, - // The API does not have a dedicated failure state for this resource, - // so we rely on the timeout for cases where it never becomes active. - } - handler := wait.New(waitConfig.Wait()) - handler.SetTimeout(15 * time.Minute) - return handler -} - -// DeleteUserWaitHandler will wait for user deletion -func DeleteUserWaitHandler(ctx context.Context, a postgresflex.DefaultAPI, projectId, region, instanceId string, userId int64) *wait.AsyncActionHandler[struct{}] { - handler := wait.New(func() (waitFinished bool, response *struct{}, err error) { - _, err = a.GetUser(ctx, projectId, region, instanceId, userId).Execute() - if err == nil { - return false, nil, nil - } - oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped - if !ok { - return false, nil, err - } - if oapiErr.StatusCode != 404 { - return false, nil, err - } - return true, nil, nil - }) - handler.SetTimeout(1 * time.Minute) - return handler -} diff --git a/services/postgresflex/v3api/wait/wait_test.go b/services/postgresflex/v3api/wait/wait_test.go deleted file mode 100644 index 84b13f383..000000000 --- a/services/postgresflex/v3api/wait/wait_test.go +++ /dev/null @@ -1,348 +0,0 @@ -package wait - -import ( - "context" - "fmt" - "testing" - "testing/synctest" - "time" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - - "github.com/stackitcloud/stackit-sdk-go/core/wait" - - "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3api" -) - -type mockSettings struct { - instanceId string - instanceState postgresflex.State - instanceIsDeleted bool - instanceGetFails bool - - usersGetErrorStatus int - - userGetFails bool - userId int64 - userIsDeleted bool - userState string -} - -// Used for testing instance operations -func newAPIMock(settings *mockSettings) postgresflex.DefaultAPI { - return &postgresflex.DefaultAPIServiceMock{ - GetInstanceExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetInstanceRequest) (*postgresflex.GetInstanceResponse, error) { - if settings.instanceGetFails { - return nil, &oapierror.GenericOpenAPIError{ - StatusCode: 500, - } - } - - if settings.instanceIsDeleted { - return nil, &oapierror.GenericOpenAPIError{ - StatusCode: 404, - } - } - - return &postgresflex.GetInstanceResponse{ - Id: settings.instanceId, - State: settings.instanceState, - }, nil - }), - ListUsersExecuteMock: utils.Ptr(func(_ postgresflex.ApiListUsersRequest) (*postgresflex.ListUsersResponse, error) { - if settings.usersGetErrorStatus != 0 { - return nil, &oapierror.GenericOpenAPIError{ - StatusCode: settings.usersGetErrorStatus, - } - } - - return &postgresflex.ListUsersResponse{ - Users: []postgresflex.ListUser{}, - }, nil - }), - GetUserExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetUserRequest) (*postgresflex.GetUserResponse, error) { - if settings.userGetFails { - return nil, &oapierror.GenericOpenAPIError{ - StatusCode: 423, - } - } - - if settings.userIsDeleted { - return nil, &oapierror.GenericOpenAPIError{ - StatusCode: 404, - } - } - - return &postgresflex.GetUserResponse{ - Id: settings.userId, - State: settings.userState, - }, nil - }), - } -} - -func TestCreateOrUpdateInstanceWaitHandler(t *testing.T) { - tests := []struct { - desc string - instanceGetFails bool - instanceState postgresflex.State - wantErr bool - wantResp bool - }{ - { - desc: "create_or_update_succeeded", - instanceGetFails: false, - instanceState: postgresflex.STATE_READY, - wantErr: false, - wantResp: true, - }, - { - desc: "create_or_update_failed", - instanceGetFails: false, - instanceState: postgresflex.STATE_FAILURE, - wantErr: true, - wantResp: true, - }, - { - desc: "create_or_update_failed_2", - instanceGetFails: false, - instanceState: postgresflex.STATE_UNKNOWN, - wantErr: true, - wantResp: true, - }, - { - desc: "instance_get_fails", - instanceGetFails: true, - wantErr: true, - wantResp: false, - }, - { - desc: "timeout", - instanceGetFails: false, - instanceState: postgresflex.STATE_PROGRESSING, - wantErr: true, - wantResp: false, - }, - { - desc: "timeout_2", - instanceGetFails: false, - instanceState: postgresflex.STATE_PENDING, - wantErr: true, - wantResp: false, - }, - } - - handlers := map[string]func(context.Context, postgresflex.DefaultAPI, string, string, string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse]{ - "common logic": createOrUpdateInstanceWaitHandler, - "create": CreateInstanceWaitHandler, - "update": PartialUpdateInstanceWaitHandler, - "clone": CloneInstanceWaitHandler, - } - - for handlerDesc, handlerFn := range handlers { - for _, tt := range tests { - t.Run(fmt.Sprintf("%s - %s", handlerDesc, tt.desc), func(t *testing.T) { - synctest.Test(t, func(t *testing.T) { - instanceId := "foo-bar" - - apiClient := newAPIMock(&mockSettings{ - instanceId: instanceId, - instanceState: tt.instanceState, - instanceGetFails: tt.instanceGetFails, - }) - - var wantRes *postgresflex.GetInstanceResponse - if tt.wantResp { - wantRes = &postgresflex.GetInstanceResponse{ - Id: instanceId, - State: tt.instanceState, - } - } - - handler := handlerFn(context.Background(), apiClient, "", "", instanceId) - gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) - - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - if !cmp.Equal(gotRes, wantRes, cmpopts.EquateComparable(postgresflex.NullableInt32{})) { - t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes) - } - }) - }) - } - } -} - -func TestDeleteInstanceWaitHandler(t *testing.T) { - tests := []struct { - desc string - instanceGetFails bool - isDeleted bool - instanceState postgresflex.State - wantErr bool - }{ - { - desc: "delete_succeeded", - isDeleted: true, - instanceGetFails: false, - wantErr: false, - }, - { - desc: "delete_failed", - instanceGetFails: false, - instanceState: postgresflex.STATE_FAILURE, - wantErr: true, - }, - { - desc: "get_fails", - instanceGetFails: true, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - synctest.Test(t, func(t *testing.T) { - instanceId := "foo-bar" - - apiClient := newAPIMock(&mockSettings{ - instanceGetFails: tt.instanceGetFails, - instanceIsDeleted: tt.isDeleted, - instanceId: instanceId, - instanceState: tt.instanceState, - }) - - handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", "", instanceId) - - _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background()) - - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - }) - }) - } -} - -func TestCreateUserWaitHandler(t *testing.T) { - tests := []struct { - desc string - userGetFails bool - userState string - usersGetErrorStatus int - wantErr bool - wantResp bool - }{ - { - desc: "create_succeeded", - userGetFails: false, - userState: "PROCESSED", - wantErr: false, - wantResp: true, - }, - { - desc: "user_get_fails", - userGetFails: true, - wantErr: true, - wantResp: false, - }, - { - desc: "users_get_fails", - userGetFails: true, - usersGetErrorStatus: 423, - wantErr: true, - wantResp: false, - }, - { - desc: "timeout", - userGetFails: false, - userState: "", - wantErr: true, - wantResp: false, - }, - } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - synctest.Test(t, func(t *testing.T) { - userId := int64(34) - - apiClient := newAPIMock(&mockSettings{ - userGetFails: tt.userGetFails, - userId: userId, - userState: tt.userState, - }) - - var wantRes *postgresflex.GetUserResponse - if tt.wantResp { - wantRes = &postgresflex.GetUserResponse{ - Id: userId, - State: tt.userState, - } - } - - handler := CreateUserWaitHandler(context.Background(), apiClient, "", "", "", userId) - - gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) - - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - if !cmp.Equal(gotRes, wantRes) { - t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes) - } - }) - }) - } -} - -func TestDeleteUserWaitHandler(t *testing.T) { - tests := []struct { - desc string - deleteFails bool - getFails bool - wantErr bool - }{ - { - desc: "delete_succeeded", - deleteFails: false, - getFails: false, - wantErr: false, - }, - { - desc: "delete_failed", - deleteFails: true, - getFails: false, - wantErr: true, - }, - { - desc: "get_fails", - deleteFails: false, - getFails: true, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - synctest.Test(t, func(t *testing.T) { - userId := int64(34) - - apiClient := newAPIMock(&mockSettings{ - userGetFails: tt.getFails, - userId: userId, - userIsDeleted: !tt.deleteFails, - }) - - handler := DeleteUserWaitHandler(context.Background(), apiClient, "", "", "", userId) - - _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background()) - - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - }) - }) - } -} diff --git a/services/postgresflex/wait/wait.go b/services/postgresflex/wait/wait.go index 2ea1632c2..499454e44 100644 --- a/services/postgresflex/wait/wait.go +++ b/services/postgresflex/wait/wait.go @@ -27,7 +27,7 @@ const ( // // Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead type APIClientInstanceInterface interface { - GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.GetInstanceResponse, error) + GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.InstanceResponse, error) ListUsersExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.ListUsersResponse, error) } @@ -35,28 +35,28 @@ type APIClientInstanceInterface interface { // // Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead type APIClientUserInterface interface { - GetUserExecute(ctx context.Context, projectId, region, instanceId string, userId int64) (*postgresflex.GetUserResponse, error) + GetUserExecute(ctx context.Context, projectId, region, instanceId, userId string) (*postgresflex.GetUserResponse, error) } // CreateInstanceWaitHandler will wait for instance creation // // Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead -func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { +func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.InstanceResponse] { instanceCreated := false - var instanceGetResponse *postgresflex.GetInstanceResponse + var instanceGetResponse *postgresflex.InstanceResponse - handler := wait.New(func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) { + handler := wait.New(func() (waitFinished bool, response *postgresflex.InstanceResponse, err error) { if !instanceCreated { s, err := a.GetInstanceExecute(ctx, projectId, region, instanceId) if err != nil { return false, nil, err } - if s == nil || s.Id == nil || *s.Id != instanceId || s.State == nil { + if s == nil || s.Item == nil || s.Item.Id == nil || *s.Item.Id != instanceId || s.Item.Status == nil { return false, nil, nil } - switch *s.State { + switch *s.Item.Status { default: - return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.State) + return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Item.Status) case InstanceStateEmpty: return false, nil, nil case InstanceStateProgressing: @@ -92,18 +92,18 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface // PartialUpdateInstanceWaitHandler will wait for instance update // // Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead -func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.GetInstanceResponse] { - handler := wait.New(func() (waitFinished bool, response *postgresflex.GetInstanceResponse, err error) { +func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, region, instanceId string) *wait.AsyncActionHandler[postgresflex.InstanceResponse] { + handler := wait.New(func() (waitFinished bool, response *postgresflex.InstanceResponse, err error) { s, err := a.GetInstanceExecute(ctx, projectId, region, instanceId) if err != nil { return false, nil, err } - if s == nil || s.Id == nil || *s.Id != instanceId || s.State == nil { + if s == nil || s.Item == nil || s.Item.Id == nil || *s.Item.Id != instanceId || s.Item.Status == nil { return false, nil, nil } - switch *s.State { + switch *s.Item.Status { default: - return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.State) + return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Item.Status) case InstanceStateEmpty: return false, nil, nil case InstanceStateProgressing: @@ -127,12 +127,12 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface if err != nil { return false, nil, err } - if s == nil || s.Id == nil || *s.Id != instanceId || s.State == nil { + if s == nil || s.Item == nil || s.Item.Id == nil || *s.Item.Id != instanceId || s.Item.Status == nil { return false, nil, nil } - switch *s.State { + switch *s.Item.Status { default: - return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.State) + return true, nil, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Item.Status) case InstanceStateSuccess: return false, nil, nil case InstanceStateDeleted: @@ -168,7 +168,7 @@ func ForceDeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInte // DeleteUserWaitHandler will wait for delete // // Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead -func DeleteUserWaitHandler(ctx context.Context, a APIClientUserInterface, projectId, region, instanceId string, userId int64) *wait.AsyncActionHandler[struct{}] { +func DeleteUserWaitHandler(ctx context.Context, a APIClientUserInterface, projectId, region, instanceId, userId string) *wait.AsyncActionHandler[struct{}] { handler := wait.New(func() (waitFinished bool, response *struct{}, err error) { _, err = a.GetUserExecute(ctx, projectId, region, instanceId, userId) if err == nil { diff --git a/services/postgresflex/wait/wait_test.go b/services/postgresflex/wait/wait_test.go index 4027208db..64da700ad 100644 --- a/services/postgresflex/wait/wait_test.go +++ b/services/postgresflex/wait/wait_test.go @@ -9,6 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" + "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" ) @@ -21,7 +22,7 @@ type apiClientInstanceMocked struct { usersGetErrorStatus int } -func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.GetInstanceResponse, error) { +func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.InstanceResponse, error) { if a.instanceGetFails { return nil, &oapierror.GenericOpenAPIError{ StatusCode: 500, @@ -34,9 +35,11 @@ func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _, _ } } - return &postgresflex.GetInstanceResponse{ - Id: &a.instanceId, - State: postgresflex.GetInstanceResponseGetStateAttributeType(&a.instanceState), + return &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Id: &a.instanceId, + Status: &a.instanceState, + }, }, nil } @@ -46,20 +49,22 @@ func (a *apiClientInstanceMocked) ListUsersExecute(_ context.Context, _, _, _ st StatusCode: a.usersGetErrorStatus, } } + + aux := int64(0) return &postgresflex.ListUsersResponse{ - Pagination: &postgresflex.Pagination{}, - Users: &[]postgresflex.ListUser{}, + Count: &aux, + Items: &[]postgresflex.ListUsersResponseItem{}, }, nil } // Used for testing user operations type apiClientUserMocked struct { getFails bool - userId int64 + userId string isUserDeleted bool } -func (a *apiClientUserMocked) GetUserExecute(_ context.Context, _, _, _ string, _ int64) (*postgresflex.GetUserResponse, error) { +func (a *apiClientUserMocked) GetUserExecute(_ context.Context, _, _, _, _ string) (*postgresflex.GetUserResponse, error) { if a.getFails { return nil, &oapierror.GenericOpenAPIError{ StatusCode: 500, @@ -73,7 +78,9 @@ func (a *apiClientUserMocked) GetUserExecute(_ context.Context, _, _, _ string, } return &postgresflex.GetUserResponse{ - Id: postgresflex.GetUserResponseGetIdAttributeType(&a.userId), + Item: &postgresflex.UserResponse{ + Id: &a.userId, + }, }, nil } @@ -149,11 +156,13 @@ func TestCreateInstanceWaitHandler(t *testing.T) { usersGetErrorStatus: tt.usersGetErrorStatus, } - var wantRes *postgresflex.GetInstanceResponse + var wantRes *postgresflex.InstanceResponse if tt.wantResp { - wantRes = &postgresflex.GetInstanceResponse{ - Id: &instanceId, - State: postgresflex.GetInstanceResponseGetStateAttributeType(&tt.instanceState), + wantRes = &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Id: &instanceId, + Status: utils.Ptr(tt.instanceState), + }, } } @@ -226,11 +235,13 @@ func TestUpdateInstanceWaitHandler(t *testing.T) { instanceGetFails: tt.instanceGetFails, } - var wantRes *postgresflex.GetInstanceResponse + var wantRes *postgresflex.InstanceResponse if tt.wantResp { - wantRes = &postgresflex.GetInstanceResponse{ - Id: &instanceId, - State: postgresflex.GetInstanceResponseGetStateAttributeType(&tt.instanceState), + wantRes = &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Id: &instanceId, + Status: utils.Ptr(tt.instanceState), + }, } } @@ -375,7 +386,7 @@ func TestDeleteUserWaitHandler(t *testing.T) { for _, tt := range tests { t.Run(tt.desc, func(t *testing.T) { synctest.Test(t, func(t *testing.T) { - userId := int64(1234) + userId := "foo-bar" apiClient := &apiClientUserMocked{ getFails: tt.getFails,