feat: refactor testing (#35)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Reviewed-on: #35
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
32e41d8b44
commit
b1b359f436
6 changed files with 486 additions and 60 deletions
|
|
@ -96,7 +96,7 @@ func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInterface, projec
|
|||
tflog.Info(ctx, "request is being handled", map[string]interface{}{
|
||||
"status": *s.Status,
|
||||
})
|
||||
return false, nil, nil
|
||||
return false, s, nil
|
||||
default:
|
||||
tflog.Info(ctx, "Wait (update) received unknown status", map[string]interface{}{
|
||||
"instanceId": instanceId,
|
||||
|
|
@ -105,17 +105,15 @@ func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInterface, projec
|
|||
return false, s, nil
|
||||
}
|
||||
})
|
||||
handler.SetSleepBeforeWait(15 * time.Second)
|
||||
handler.SetTimeout(45 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
||||
// DeleteInstanceWaitHandler will wait for instance deletion
|
||||
func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[struct{}] {
|
||||
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
|
||||
_, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] {
|
||||
handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
|
||||
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
|
||||
if err == nil {
|
||||
return false, nil, nil
|
||||
return false, s, nil
|
||||
}
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
ok := errors.As(err, &oapiErr)
|
||||
|
|
@ -127,7 +125,7 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInterface, projec
|
|||
}
|
||||
return true, nil, nil
|
||||
})
|
||||
handler.SetTimeout(15 * time.Minute)
|
||||
handler.SetTimeout(30 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue