Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
nexedi
caddy
Commits
c59fd1c7
Commit
c59fd1c7
authored
Feb 01, 2016
by
MathiasB
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Defined test function in TestBuildEnv
parent
ac197f16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
middleware/fastcgi/fastcgi_test.go
middleware/fastcgi/fastcgi_test.go
+18
-18
No files found.
middleware/fastcgi/fastcgi_test.go
View file @
c59fd1c7
...
...
@@ -32,25 +32,25 @@ func TestRuleParseAddress(t *testing.T) {
}
func
BuildEnvSingle
(
r
*
http
.
Request
,
rule
Rule
,
fpath
string
,
envExpected
map
[
string
]
string
,
t
*
testing
.
T
)
{
h
:=
Handler
{}
env
,
err
:=
h
.
buildEnv
(
r
,
rule
,
fpath
)
if
err
!=
nil
{
t
.
Error
(
"Unexpected error:"
,
err
.
Error
())
}
func
TestBuildEnv
(
t
*
testing
.
T
)
{
for
k
,
v
:=
range
envExpected
{
if
env
[
k
]
!=
v
{
t
.
Errorf
(
"Unexpected %v. Got %v, expected %v"
,
k
,
env
[
k
],
v
)
buildEnvSingle
:=
func
(
r
*
http
.
Request
,
rule
Rule
,
fpath
string
,
envExpected
map
[
string
]
string
,
t
*
testing
.
T
)
{
h
:=
Handler
{}
env
,
err
:=
h
.
buildEnv
(
r
,
rule
,
fpath
)
if
err
!=
nil
{
t
.
Error
(
"Unexpected error:"
,
err
.
Error
())
}
for
k
,
v
:=
range
envExpected
{
if
env
[
k
]
!=
v
{
t
.
Errorf
(
"Unexpected %v. Got %v, expected %v"
,
k
,
env
[
k
],
v
)
}
}
}
}
func
TestBuildEnv
(
t
*
testing
.
T
)
{
rule
:=
Rule
{}
url
,
err
:=
url
.
Parse
(
"http://localhost:2015/fgci_test.php?test=blabla"
)
if
err
!=
nil
{
...
...
@@ -80,16 +80,16 @@ func TestBuildEnv(t *testing.T) {
}
// 1. Test for full canonical IPv6 address
B
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
b
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
// 2. Test for shorthand notation of IPv6 address
r
.
RemoteAddr
=
"[::1]:51688"
envExpected
[
"REMOTE_ADDR"
]
=
"[::1]"
B
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
b
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
// 3. Test for IPv4 address
r
.
RemoteAddr
=
"192.168.0.10:51688"
envExpected
[
"REMOTE_ADDR"
]
=
"192.168.0.10"
B
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
b
uildEnvSingle
(
&
r
,
rule
,
fpath
,
envExpected
,
t
)
}
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