| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package streamserver |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 "os" |
| 10 "strings" |
| 11 "testing" |
| 12 |
| 13 "github.com/luci/luci-go/logdog/client/butlerlib/streamclient" |
| 14 |
| 15 "golang.org/x/net/context" |
| 16 |
| 17 . "github.com/luci/luci-go/common/testing/assertions" |
| 18 . "github.com/smartystreets/goconvey/convey" |
| 19 ) |
| 20 |
| 21 func TestWindowsNamedPipeServer(t *testing.T) { |
| 22 t.Parallel() |
| 23 |
| 24 pid := os.Getpid() |
| 25 |
| 26 Convey(`A named pipe server`, t, func() { |
| 27 ctx := context.Background() |
| 28 |
| 29 Convey(`Will refuse to create if there is an empty path.`, func(
) { |
| 30 _, err := NewNamedPipeServer(ctx, "") |
| 31 So(err, ShouldErrLike, "cannot have empty name") |
| 32 }) |
| 33 |
| 34 Convey(`Will refuse to create if longer than maximum length.`, f
unc() { |
| 35 _, err := NewNamedPipeServer(ctx, strings.Repeat("A", ma
xWindowsNamedPipeLength+1)) |
| 36 So(err, ShouldErrLike, "name exceeds maximum length") |
| 37 }) |
| 38 |
| 39 Convey(`When created and listening.`, func() { |
| 40 svr, err := NewNamedPipeServer(ctx, fmt.Sprintf("ButlerN
amedPipeTest_%d", pid)) |
| 41 So(err, ShouldBeNil) |
| 42 |
| 43 So(svr.Listen(), ShouldBeNil) |
| 44 defer svr.Close() |
| 45 |
| 46 client, err := streamclient.New(svr.Address()) |
| 47 So(err, ShouldBeNil) |
| 48 |
| 49 testClientServer(t, svr, client) |
| 50 }) |
| 51 }) |
| 52 } |
| OLD | NEW |