From 887606114902bd58c3838767ac2b66dadba27e5e Mon Sep 17 00:00:00 2001 From: Jack Lindamood Date: Fri, 15 Jul 2016 13:28:27 -0700 Subject: context: add test for WithDeadline in the past Adds a test case for calling context.WithDeadline() where the deadline exists in the past. This change increases the code coverage of the context package. Change-Id: Ib486bf6157e779fafd9dab2b7364cdb5a06be36e Reviewed-on: https://go-review.googlesource.com/25007 Reviewed-by: Sameer Ajmani Run-TryBot: Sameer Ajmani TryBot-Result: Gobot Gobot --- src/context/context_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/context/context_test.go b/src/context/context_test.go index 90e78e57ec..cf182110fb 100644 --- a/src/context/context_test.go +++ b/src/context/context_test.go @@ -255,6 +255,12 @@ func TestDeadline(t *testing.T) { o = otherContext{c} c, _ = WithDeadline(o, time.Now().Add(4*time.Second)) testDeadline(c, "WithDeadline+otherContext+WithDeadline", 2*time.Second, t) + + c, _ = WithDeadline(Background(), time.Now().Add(-time.Millisecond)) + testDeadline(c, "WithDeadline+inthepast", time.Second, t) + + c, _ = WithDeadline(Background(), time.Now()) + testDeadline(c, "WithDeadline+now", time.Second, t) } func TestTimeout(t *testing.T) { -- cgit v1.2.3-54-g00ecf