Skip to content

Commit 23537a8

Browse files
committed
test(aws): trim sleepContext test to the cancellation case only
The happy-path test was a trivial sanity check (sleepContext returns nil on success). The cancellation case is the one that actually exercises the new code path. Verbose docstrings removed. Linear: LIB-4933
1 parent a5b5c6a commit 23537a8

1 file changed

Lines changed: 2 additions & 20 deletions

File tree

modules/aws/iam_internal_test.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,22 @@ import (
77
"time"
88
)
99

10-
// TestSleepContextHonorsCancellation verifies that sleepContext returns promptly
11-
// with context.Canceled when the context is cancelled mid-sleep, rather than
12-
// waiting the full duration.
1310
func TestSleepContextHonorsCancellation(t *testing.T) {
1411
t.Parallel()
1512

1613
ctx, cancel := context.WithCancel(context.Background())
17-
18-
// Cancel after a short delay so we can verify the sleep is interrupted.
1914
go func() {
2015
time.Sleep(50 * time.Millisecond)
2116
cancel()
2217
}()
2318

2419
start := time.Now()
2520
err := sleepContext(ctx, 30*time.Second)
26-
elapsed := time.Since(start)
2721

2822
if !errors.Is(err, context.Canceled) {
2923
t.Fatalf("expected context.Canceled, got %v", err)
3024
}
31-
32-
if elapsed > 5*time.Second {
33-
t.Fatalf("sleepContext did not return promptly after cancellation; took %v", elapsed)
34-
}
35-
}
36-
37-
// TestSleepContextCompletesNormally verifies that sleepContext returns nil
38-
// when the duration elapses before the context is cancelled.
39-
func TestSleepContextCompletesNormally(t *testing.T) {
40-
t.Parallel()
41-
42-
ctx := context.Background()
43-
if err := sleepContext(ctx, 10*time.Millisecond); err != nil {
44-
t.Fatalf("expected nil error, got %v", err)
25+
if time.Since(start) > 5*time.Second {
26+
t.Fatalf("sleepContext did not return promptly after cancellation")
4527
}
4628
}

0 commit comments

Comments
 (0)