OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / net / context / ctxhttp / ctxhttp_17_test.go
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build !plan9,go1.7
6
7 package ctxhttp
8
9 import (
10         "io"
11         "net/http"
12         "net/http/httptest"
13         "testing"
14
15         "context"
16 )
17
18 func TestGo17Context(t *testing.T) {
19         ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
20                 io.WriteString(w, "ok")
21         }))
22         defer ts.Close()
23         ctx := context.Background()
24         resp, err := Get(ctx, http.DefaultClient, ts.URL)
25         if resp == nil || err != nil {
26                 t.Fatalf("error received from client: %v %v", err, resp)
27         }
28         resp.Body.Close()
29 }