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 4m1s
CI Workflow / CI run build and linting (pull_request) Failing after 5m1s
CI Workflow / CI run tests (pull_request) Failing after 5m16s
CI Workflow / Code coverage report (pull_request) Has been skipped
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 4m1s
CI Workflow / CI run build and linting (pull_request) Failing after 5m1s
CI Workflow / CI run tests (pull_request) Failing after 5m16s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
d6d3a795bb
commit
7f5802aff0
27 changed files with 802 additions and 962 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -207,11 +208,14 @@ func GetUserByIdWaitHandler(
|
|||
ctx context.Context,
|
||||
a APIClientUserInterface,
|
||||
projectId, instanceId, region string,
|
||||
userId int32,
|
||||
userId int64,
|
||||
) *wait.AsyncActionHandler[v3alpha1api.GetUserResponse] {
|
||||
handler := wait.New(
|
||||
func() (waitFinished bool, response *v3alpha1api.GetUserResponse, err error) {
|
||||
userId32 := userId
|
||||
if userId > math.MaxInt32 {
|
||||
return false, nil, fmt.Errorf("userID too large for int32")
|
||||
}
|
||||
userId32 := int32(userId)
|
||||
s, err := a.GetUserRequest(ctx, projectId, region, instanceId, userId32).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
|
|
@ -243,11 +247,14 @@ func GetDatabaseByIdWaitHandler(
|
|||
ctx context.Context,
|
||||
a APIClientDatabaseInterface,
|
||||
projectId, instanceId, region string,
|
||||
databaseId int32,
|
||||
databaseId int64,
|
||||
) *wait.AsyncActionHandler[v3alpha1api.GetDatabaseResponse] {
|
||||
handler := wait.New(
|
||||
func() (waitFinished bool, response *v3alpha1api.GetDatabaseResponse, err error) {
|
||||
dbId32 := databaseId
|
||||
if databaseId > math.MaxInt32 {
|
||||
return false, nil, fmt.Errorf("databaseID too large for int32")
|
||||
}
|
||||
dbId32 := int32(databaseId)
|
||||
s, err := a.GetDatabaseRequest(ctx, projectId, region, instanceId, dbId32).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ type apiClientInstanceMocked struct {
|
|||
func (a *apiClientInstanceMocked) GetInstanceRequest(
|
||||
_ context.Context,
|
||||
_, _, _ string,
|
||||
) *postgresflex.ApiGetInstanceRequestRequest {
|
||||
) postgresflex.ApiGetInstanceRequestRequest {
|
||||
return postgresflex.ApiGetInstanceRequestRequest{}
|
||||
}
|
||||
|
||||
func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
|
||||
|
|
@ -53,6 +54,13 @@ func (a *apiClientInstanceMocked) GetInstanceRequestExecute(
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (a *apiClientInstanceMocked) ListUsersRequest(
|
||||
_ context.Context,
|
||||
_, _, _ string,
|
||||
) postgresflex.ApiListUsersRequestRequest {
|
||||
return postgresflex.ApiListUsersRequestRequest{}
|
||||
}
|
||||
|
||||
func (a *apiClientInstanceMocked) ListUsersRequestExecute(
|
||||
_ context.Context,
|
||||
_, _, _ string,
|
||||
|
|
@ -210,13 +218,13 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
|
|||
GetInstanceRequestExecuteMock: nil,
|
||||
}
|
||||
|
||||
apiClient := &apiClientInstanceMocked{
|
||||
instanceId: instanceId,
|
||||
instanceState: tt.instanceState,
|
||||
instanceNetwork: tt.instanceNetwork,
|
||||
instanceGetFails: tt.instanceGetFails,
|
||||
usersGetErrorStatus: tt.usersGetErrorStatus,
|
||||
}
|
||||
//apiClient := &apiClientInstanceMocked{
|
||||
// instanceId: instanceId,
|
||||
// instanceState: tt.instanceState,
|
||||
// instanceNetwork: tt.instanceNetwork,
|
||||
// instanceGetFails: tt.instanceGetFails,
|
||||
// usersGetErrorStatus: tt.usersGetErrorStatus,
|
||||
//}
|
||||
|
||||
handler := CreateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceId)
|
||||
|
||||
|
|
@ -254,9 +262,9 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
wantErr: false,
|
||||
wantRes: &postgresflex.GetInstanceResponse{
|
||||
Id: utils.Ptr("foo-bar"),
|
||||
Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateSuccess)),
|
||||
Network: &postgresflex.InstanceNetwork{
|
||||
Id: "foo-bar",
|
||||
Status: postgresflex.Status(InstanceStateSuccess),
|
||||
Network: postgresflex.InstanceNetwork{
|
||||
AccessScope: nil,
|
||||
Acl: nil,
|
||||
InstanceAddress: utils.Ptr("10.0.0.1"),
|
||||
|
|
@ -276,9 +284,9 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
|
|||
},
|
||||
wantErr: true,
|
||||
wantRes: &postgresflex.GetInstanceResponse{
|
||||
Id: utils.Ptr("foo-bar"),
|
||||
Status: postgresflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(InstanceStateFailed)),
|
||||
Network: &postgresflex.InstanceNetwork{
|
||||
Id: "foo-bar",
|
||||
Status: postgresflex.Status(InstanceStateFailed),
|
||||
Network: postgresflex.InstanceNetwork{
|
||||
AccessScope: nil,
|
||||
Acl: nil,
|
||||
InstanceAddress: utils.Ptr("10.0.0.1"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue