aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Lindamood <jlindamo@justin.tv>2016-07-15 13:28:27 -0700
committerSameer Ajmani <sameer@golang.org>2016-07-26 14:53:38 +0000
commit887606114902bd58c3838767ac2b66dadba27e5e (patch)
tree5c4c8eb0827478313e1bd464b3ce79a647fc8710
parentea2376fcea0be75c856ebd199c0ad0f98192d406 (diff)
downloadgo-887606114902bd58c3838767ac2b66dadba27e5e.tar.gz
go-887606114902bd58c3838767ac2b66dadba27e5e.zip
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 <sameer@golang.org> Run-TryBot: Sameer Ajmani <sameer@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/context/context_test.go6
1 files changed, 6 insertions, 0 deletions
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) {