Commit c10f8700 authored by Jaana Burcu Dogan's avatar Jaana Burcu Dogan

net/http/httptrace: test the order of hooks when ctx has multi ClientTraces

Change-Id: I95cae14bb5561947ada9577fb05053f93321a4a8
Reviewed-on: https://go-review.googlesource.com/27400
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a072fc2e
......@@ -6,9 +6,36 @@ 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment