From 693f74258b9d20862052c84492b2e69187b1b39c Mon Sep 17 00:00:00 2001 From: sime1 Date: Tue, 26 Mar 2019 18:36:36 +0100 Subject: [PATCH] context timeout test --- pipe_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pipe_test.go b/pipe_test.go index 964cadc..89e32d1 100644 --- a/pipe_test.go +++ b/pipe_test.go @@ -38,6 +38,20 @@ func TestDialListenerTimesOut(t *testing.T) { } } +func TestDialContextListenerTimesOut(t *testing.T) { + l, err := ListenPipe(testPipeName, nil) + if err != nil { + t.Fatal(err) + } + defer l.Close() + var d = time.Duration(10 * time.Millisecond) + ctx, _ := context.WithTimeout(context.Background(), d) + _, err = DialPipeContext(ctx, testPipeName) + if err != context.DeadlineExceeded { + t.Fatalf("expected context.DeadlineExceeded, got %v", err) + } +} + func TestDialListenerGetsCancelled(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) l, err := ListenPipe(testPipeName, nil)