fix: adjust tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Prepare GO cache (pull_request) Successful in 5m57s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 15m57s
CI Workflow / CI run build and linting (pull_request) Successful in 20m47s
CI Workflow / Code coverage report (pull_request) Successful in 15s
CI Workflow / CI run tests (pull_request) Failing after 1h16m42s

This commit is contained in:
Marcel S. Henselin 2026-03-13 18:09:34 +01:00
parent bb3a2a37b1
commit a8701d37e6
4 changed files with 33 additions and 13 deletions

View file

@ -171,8 +171,6 @@ func CreateInstanceWaitHandler(
return false, nil, nil
},
)
// Sleep before wait is set because sometimes API returns 404 right after creation request
handler.SetTimeout(90 * time.Minute).SetSleepBeforeWait(30 * time.Second)
return handler
}
@ -222,7 +220,6 @@ func PartialUpdateInstanceWaitHandler(
}
},
)
handler.SetTimeout(45 * time.Minute).SetSleepBeforeWait(30 * time.Second)
return handler
}

View file

@ -22,6 +22,7 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
usersGetErrorStatus int
wantErr bool
wantRes *v3alpha1api.GetInstanceResponse
timeout time.Duration
}{
{
desc: "create_succeeded",
@ -56,7 +57,17 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
RouterAddress: utils.Ptr("10.0.0.1"),
},
wantErr: true,
wantRes: nil,
wantRes: &v3alpha1api.GetInstanceResponse{
Id: "foo-bar",
Status: InstanceStateFailed,
Network: v3alpha1api.InstanceNetwork{
AccessScope: nil,
Acl: nil,
InstanceAddress: utils.Ptr("10.0.0.1"),
RouterAddress: utils.Ptr("10.0.0.1"),
},
},
timeout: 30 * time.Second,
},
{
desc: "create_failed_2",
@ -181,9 +192,13 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
ListUsersRequestExecuteMock: &listUsersMock,
}
handler := CreateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID)
handler := CreateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID).
SetTimeout(10 * time.Millisecond)
if tt.timeout != 0 {
handler.SetTimeout(tt.timeout)
}
gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
gotRes, err := handler.SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background())
if (err != nil) != tt.wantErr {
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
}
@ -204,6 +219,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
instanceNetwork v3alpha1api.InstanceNetwork
wantErr bool
wantRes *v3alpha1api.GetInstanceResponse
timeout time.Duration
}{
{
desc: "update_succeeded",
@ -248,6 +264,7 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
RouterAddress: utils.Ptr("10.0.0.1"),
},
},
timeout: 30 * time.Second,
},
{
desc: "update_failed_2",
@ -316,9 +333,13 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
ListUsersRequestExecuteMock: &listUsersMock,
}
handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID)
handler := PartialUpdateInstanceWaitHandler(context.Background(), apiClientMock, "", "", instanceID).
SetTimeout(10 * time.Millisecond)
if tt.timeout > 0 {
handler.SetTimeout(tt.timeout)
}
gotRes, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background())
gotRes, err := handler.WaitWithContext(context.Background())
if (err != nil) != tt.wantErr {
t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr)
}