-
Notifications
You must be signed in to change notification settings - Fork 2
/
wait.go
41 lines (36 loc) · 1.31 KB
/
wait.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
package types
import (
"time"
)
// Wait contains information about the duration within which a Spec should
// run along with whether a deadline exceeded/timeout error should be expected
// or not.
type Wait struct {
// Before is the amount of time that the test unit should wait before
// executing its action.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
Before string `yaml:"before,omitempty"`
// After is the amount of time that the test unit should wait after
// executing its action.
// Specify a duration using Go's time duration string.
// See https://pkg.go.dev/time#ParseDuration
After string `yaml:"after,omitempty"`
}
// BeforeDuration returns the time duration of the Wait.Before
func (w *Wait) BeforeDuration() time.Duration {
// Parsing already validated the duration string so no need to check again
// here
dur, _ := time.ParseDuration(w.Before)
return dur
}
// AfterDuration returns the time duration of the Wait.After
func (w *Wait) AfterDuration() time.Duration {
// Parsing already validated the duration string so no need to check again
// here
dur, _ := time.ParseDuration(w.After)
return dur
}