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
Łukasz Nowak
caddy
Commits
d96bd526
Commit
d96bd526
authored
9 years ago
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #235 from Karthic-Hackintosh/master
middleware: Complete test coverage for replacer
parents
f8e2cc80
ed4148f2
master
nxd-v0.11.0
nxd-v0.11.0-plugins
v0.11.0
v0.10.14
v0.10.13
v0.10.12
v0.10.11
v0.10.10
v0.10.9
v0.10.8
v0.10.7
v0.10.6
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.5
v0.9.4
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.9-beta.2
v0.9-beta.1
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.8-beta.4
v0.8-beta.3
v0.8-beta.2
v0.8-beta.1
v0.7.6
nxd-v0.11.0-3-g12438f6cff8c15f307631151eb064cec579b7605
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
config/setup/fastcgi_test.go
config/setup/fastcgi_test.go
+10
-0
middleware/browse/browse_test.go
middleware/browse/browse_test.go
+1
-1
middleware/replacer_test.go
middleware/replacer_test.go
+33
-0
No files found.
config/setup/fastcgi_test.go
View file @
d96bd526
...
@@ -51,6 +51,16 @@ func TestFastcgiParse(t *testing.T) {
...
@@ -51,6 +51,16 @@ func TestFastcgiParse(t *testing.T) {
SplitPath
:
".php"
,
SplitPath
:
".php"
,
IndexFiles
:
[]
string
{
"index.php"
},
IndexFiles
:
[]
string
{
"index.php"
},
}}},
}}},
{
`fastcgi / 127.0.0.1:9001 {
split .html
}`
,
false
,
[]
fastcgi
.
Rule
{{
Path
:
"/"
,
Address
:
"127.0.0.1:9001"
,
Ext
:
""
,
SplitPath
:
".html"
,
IndexFiles
:
[]
string
{},
}}},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
NewTestController
(
test
.
inputFastcgiConfig
)
c
:=
NewTestController
(
test
.
inputFastcgiConfig
)
...
...
This diff is collapsed.
Click to expand it.
middleware/browse/browse_test.go
View file @
d96bd526
This diff is collapsed.
Click to expand it.
middleware/replacer_test.go
View file @
d96bd526
...
@@ -22,6 +22,7 @@ func TestNewReplacer(t *testing.T) {
...
@@ -22,6 +22,7 @@ func TestNewReplacer(t *testing.T) {
switch
v
:=
replaceValues
.
(
type
)
{
switch
v
:=
replaceValues
.
(
type
)
{
case
replacer
:
case
replacer
:
if
v
.
replacements
[
"{host}"
]
!=
"caddyserver.com"
{
if
v
.
replacements
[
"{host}"
]
!=
"caddyserver.com"
{
t
.
Errorf
(
"Expected host to be caddyserver.com"
)
t
.
Errorf
(
"Expected host to be caddyserver.com"
)
}
}
...
@@ -36,3 +37,35 @@ func TestNewReplacer(t *testing.T) {
...
@@ -36,3 +37,35 @@ func TestNewReplacer(t *testing.T) {
t
.
Fatalf
(
"Return Value from New Replacer expected pass type assertion into a replacer type
\n
"
)
t
.
Fatalf
(
"Return Value from New Replacer expected pass type assertion into a replacer type
\n
"
)
}
}
}
}
func
TestReplace
(
t
*
testing
.
T
)
{
w
:=
httptest
.
NewRecorder
()
recordRequest
:=
NewResponseRecorder
(
w
)
userJson
:=
`{"username": "dennis"}`
reader
:=
strings
.
NewReader
(
userJson
)
//Convert string to reader
request
,
err
:=
http
.
NewRequest
(
"POST"
,
"http://caddyserver.com"
,
reader
)
//Create request with JSON body
if
err
!=
nil
{
t
.
Fatalf
(
"Request Formation Failed
\n
"
)
}
replaceValues
:=
NewReplacer
(
request
,
recordRequest
,
""
)
switch
v
:=
replaceValues
.
(
type
)
{
case
replacer
:
if
v
.
Replace
(
"This host is {host}"
)
!=
"This host is caddyserver.com"
{
t
.
Errorf
(
"Expected host replacement failed"
)
}
if
v
.
Replace
(
"This request method is {method}"
)
!=
"This request method is POST"
{
t
.
Errorf
(
"Expected method replacement failed"
)
}
if
v
.
Replace
(
"The response status is {status}"
)
!=
"The response status is 200"
{
t
.
Errorf
(
"Expected status replacement failed"
)
}
default
:
t
.
Fatalf
(
"Return Value from New Replacer expected pass type assertion into a replacer type
\n
"
)
}
}
This diff is collapsed.
Click to expand it.
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