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
e043bbdd
Commit
e043bbdd
authored
Jul 27, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #203 from Karthic-Hackintosh/master
Test setup func for fastcgi.go
parents
c6b2600c
094436c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
config/setup/fastcgi_test.go
config/setup/fastcgi_test.go
+61
-0
No files found.
config/setup/fastcgi_test.go
View file @
e043bbdd
package
setup
import
(
"fmt"
"github.com/mholt/caddy/middleware/fastcgi"
"testing"
)
...
...
@@ -34,3 +35,63 @@ func TestFastCGI(t *testing.T) {
}
}
func
TestFastcgiParse
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
inputFastcgiConfig
string
shouldErr
bool
expectedFastcgiConfig
[]
fastcgi
.
Rule
}{
{
`fastcgi /blog 127.0.0.1:9000 php`
,
false
,
[]
fastcgi
.
Rule
{{
Path
:
"/blog"
,
Address
:
"127.0.0.1:9000"
,
Ext
:
".php"
,
SplitPath
:
".php"
,
IndexFiles
:
[]
string
{
"index.php"
},
}}},
}
for
i
,
test
:=
range
tests
{
c
:=
NewTestController
(
test
.
inputFastcgiConfig
)
actualFastcgiConfigs
,
err
:=
fastcgiParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
t
.
Errorf
(
"Test %d didn't error, but it should have"
,
i
)
}
else
if
err
!=
nil
&&
!
test
.
shouldErr
{
t
.
Errorf
(
"Test %d errored, but it shouldn't have; got '%v'"
,
i
,
err
)
}
if
len
(
actualFastcgiConfigs
)
!=
len
(
test
.
expectedFastcgiConfig
)
{
t
.
Fatalf
(
"Test %d expected %d no of FastCGI configs, but got %d "
,
i
,
len
(
test
.
expectedFastcgiConfig
),
len
(
actualFastcgiConfigs
))
}
for
j
,
actualFastcgiConfig
:=
range
actualFastcgiConfigs
{
if
actualFastcgiConfig
.
Path
!=
test
.
expectedFastcgiConfig
[
j
]
.
Path
{
t
.
Errorf
(
"Test %d expected %dth FastCGI Path to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
Path
,
actualFastcgiConfig
.
Path
)
}
if
actualFastcgiConfig
.
Address
!=
test
.
expectedFastcgiConfig
[
j
]
.
Address
{
t
.
Errorf
(
"Test %d expected %dth FastCGI Address to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
Address
,
actualFastcgiConfig
.
Address
)
}
if
actualFastcgiConfig
.
Ext
!=
test
.
expectedFastcgiConfig
[
j
]
.
Ext
{
t
.
Errorf
(
"Test %d expected %dth FastCGI Ext to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
Ext
,
actualFastcgiConfig
.
Ext
)
}
if
actualFastcgiConfig
.
SplitPath
!=
test
.
expectedFastcgiConfig
[
j
]
.
SplitPath
{
t
.
Errorf
(
"Test %d expected %dth FastCGI SplitPath to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
SplitPath
,
actualFastcgiConfig
.
SplitPath
)
}
if
fmt
.
Sprint
(
actualFastcgiConfig
.
IndexFiles
)
!=
fmt
.
Sprint
(
test
.
expectedFastcgiConfig
[
j
]
.
IndexFiles
)
{
t
.
Errorf
(
"Test %d expected %dth FastCGI IndexFiles to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
IndexFiles
,
actualFastcgiConfig
.
IndexFiles
)
}
}
}
}
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