diff options
| author | Will Hawkins <[email protected]> | 2023-02-10 18:13:03 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2023-02-10 18:13:03 -0500 |
| commit | 0eafb34d7e2c9971c9341878a7c1d3ffa034418b (patch) | |
| tree | 1ce060ef70254b465baedfc535d418ee231f6aeb /timeoutat/timeoutat_test.go | |
| parent | c8350c13a09b8c19656cd32a065b69693b6117c5 (diff) | |
[Cleanup] Update timeoutat.TimeoutAt to remove extraneous go func
Also, add a test for timeoutat.TimeoutAt.
Diffstat (limited to 'timeoutat/timeoutat_test.go')
| -rw-r--r-- | timeoutat/timeoutat_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/timeoutat/timeoutat_test.go b/timeoutat/timeoutat_test.go new file mode 100644 index 0000000..b0c91fe --- /dev/null +++ b/timeoutat/timeoutat_test.go @@ -0,0 +1,27 @@ +package timeoutat + +import ( + "context" + "testing" + "time" + + "github.com/network-quality/goresponsiveness/debug" +) + +func TestTimeoutAt(t *testing.T) { + testTime := 5 * time.Second + testTimeLimit := 6 * time.Second + + now := time.Now() + select { + case <-TimeoutAt(context.Background(), time.Now().Add(testTime), debug.NoDebug): + + } + then := time.Now() + + actualTime := then.Sub(now) + + if actualTime >= testTimeLimit { + t.Fatalf("Should have taken 5 seconds but it really took %v!", actualTime) + } +} |
