mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
chore: improve integration tests (#8727)
Improve integration tests: - spliting the tests in TokenExchange to isolated instances and in parallel - corrected some test structure so that the check for Details is no done anymore if the test already failed - replace required-calls with assert-calls to not stop the testing - add gofakeit for application, project and usernames(emails) - add eventually checks for testing in actions v2, so the request only get called when the execution is defined - check for length of results in list/search endpoints to avoid index errors
This commit is contained in:
30
internal/integration/context.go
Normal file
30
internal/integration/context.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// WaitForAndTickWithMaxDuration determine a duration and interval for EventuallyWithT-tests from context timeout and desired max duration
|
||||
func WaitForAndTickWithMaxDuration(ctx context.Context, max time.Duration) (time.Duration, time.Duration) {
|
||||
// interval which is used to retry the test
|
||||
tick := time.Millisecond * 100
|
||||
// tolerance which is used to stop the test for the timeout
|
||||
tolerance := tick * 5
|
||||
// default of the WaitFor is always a defined duration, shortened if the context would time out before
|
||||
waitFor := max
|
||||
|
||||
if ctxDeadline, ok := ctx.Deadline(); ok {
|
||||
// if the context has a deadline, set the WaitFor to the shorter duration
|
||||
if until := time.Until(ctxDeadline); until < waitFor {
|
||||
// ignore durations which are smaller than the tolerance
|
||||
if until < tolerance {
|
||||
waitFor = 0
|
||||
} else {
|
||||
// always let the test stop with tolerance before the context is in timeout
|
||||
waitFor = until - tolerance
|
||||
}
|
||||
}
|
||||
}
|
||||
return waitFor, tick
|
||||
}
|
Reference in New Issue
Block a user