Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
29df7bb7
Commit
29df7bb7
authored
Aug 09, 2011
by
Yasuhiro Matsumoto
Committed by
Brad Fitzpatrick
Aug 09, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add test to serve content in index.html
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/4798071
parent
1adda460
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
fs_test.go
src/pkg/http/fs_test.go
+21
-0
index.html
src/pkg/http/testdata/index.html
+1
-0
No files found.
src/pkg/http/fs_test.go
View file @
29df7bb7
...
@@ -261,6 +261,27 @@ func TestServeFileWithContentEncoding(t *testing.T) {
...
@@ -261,6 +261,27 @@ func TestServeFileWithContentEncoding(t *testing.T) {
}
}
}
}
func
TestServeIndexHtml
(
t
*
testing
.
T
)
{
const
want
=
"index.html says hello
\n
"
ts
:=
httptest
.
NewServer
(
FileServer
(
Dir
(
"."
)))
defer
ts
.
Close
()
for
_
,
path
:=
range
[]
string
{
"/testdata/"
,
"/testdata/index.html"
}
{
res
,
err
:=
Get
(
ts
.
URL
+
path
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
res
.
Body
.
Close
()
b
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
t
.
Fatal
(
"reading Body:"
,
err
)
}
if
s
:=
string
(
b
);
s
!=
want
{
t
.
Errorf
(
"for path %q got %q, want %q"
,
path
,
s
,
want
)
}
}
}
func
getBody
(
t
*
testing
.
T
,
req
Request
)
(
*
Response
,
[]
byte
)
{
func
getBody
(
t
*
testing
.
T
,
req
Request
)
(
*
Response
,
[]
byte
)
{
r
,
err
:=
DefaultClient
.
Do
(
&
req
)
r
,
err
:=
DefaultClient
.
Do
(
&
req
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
src/pkg/http/testdata/index.html
0 → 100644
View file @
29df7bb7
index.html says hello
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