Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
8e1fa760
Commit
8e1fa760
authored
Mar 10, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: don't hit external network in client_test.go
More reliable. R=rsc CC=golang-dev
https://golang.org/cl/4249068
parent
aae7b695
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
src/pkg/http/client_test.go
src/pkg/http/client_test.go
+16
-5
No files found.
src/pkg/http/client_test.go
View file @
8e1fa760
...
...
@@ -4,20 +4,28 @@
// Tests for client.go
package
http
package
http
_test
import
(
"fmt"
.
"http"
"http/httptest"
"io/ioutil"
"os"
"strings"
"testing"
)
var
robotsTxtHandler
=
HandlerFunc
(
func
(
w
ResponseWriter
,
r
*
Request
)
{
w
.
Header
()
.
Set
(
"Last-Modified"
,
"sometime"
)
fmt
.
Fprintf
(
w
,
"User-agent: go
\n
Disallow: /something/"
)
})
func
TestClient
(
t
*
testing
.
T
)
{
// TODO: add a proper test suite. Current test merely verifies that
// we can retrieve the Google robots.txt file.
ts
:=
httptest
.
NewServer
(
robotsTxtHandler
)
defer
ts
.
Close
()
r
,
_
,
err
:=
Get
(
"http://www.google.com/robots.txt"
)
r
,
_
,
err
:=
Get
(
ts
.
URL
)
var
b
[]
byte
if
err
==
nil
{
b
,
err
=
ioutil
.
ReadAll
(
r
.
Body
)
...
...
@@ -31,7 +39,10 @@ func TestClient(t *testing.T) {
}
func
TestClientHead
(
t
*
testing
.
T
)
{
r
,
err
:=
Head
(
"http://www.google.com/robots.txt"
)
ts
:=
httptest
.
NewServer
(
robotsTxtHandler
)
defer
ts
.
Close
()
r
,
err
:=
Head
(
ts
.
URL
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment