summaryrefslogtreecommitdiff
path: root/libgo/go/net/http/httptrace/trace_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/httptrace/trace_test.go')
-rw-r--r--libgo/go/net/http/httptrace/trace_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/libgo/go/net/http/httptrace/trace_test.go b/libgo/go/net/http/httptrace/trace_test.go
index c7eaed83d47..bb57ada8531 100644
--- a/libgo/go/net/http/httptrace/trace_test.go
+++ b/libgo/go/net/http/httptrace/trace_test.go
@@ -1,14 +1,41 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.h
+// license that can be found in the LICENSE file.
package httptrace
import (
"bytes"
+ "context"
"testing"
)
+func TestWithClientTrace(t *testing.T) {
+ var buf bytes.Buffer
+ connectStart := func(b byte) func(network, addr string) {
+ return func(network, addr string) {
+ buf.WriteByte(b)
+ }
+ }
+
+ ctx := context.Background()
+ oldtrace := &ClientTrace{
+ ConnectStart: connectStart('O'),
+ }
+ ctx = WithClientTrace(ctx, oldtrace)
+ newtrace := &ClientTrace{
+ ConnectStart: connectStart('N'),
+ }
+ ctx = WithClientTrace(ctx, newtrace)
+ trace := ContextClientTrace(ctx)
+
+ buf.Reset()
+ trace.ConnectStart("net", "addr")
+ if got, want := buf.String(), "NO"; got != want {
+ t.Errorf("got %q; want %q", got, want)
+ }
+}
+
func TestCompose(t *testing.T) {
var buf bytes.Buffer
var testNum int