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
bb072fae
Commit
bb072fae
authored
Aug 08, 2015
by
Karthic Rao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial test for middleware/middleware.go
parent
a2be7b45
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
middleware/middleware_test.go
middleware/middleware_test.go
+41
-0
No files found.
middleware/middleware_test.go
0 → 100644
View file @
bb072fae
package
middleware
import
(
"net/http"
"testing"
)
func
TestIndexfile
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
rootDir
http
.
FileSystem
fpath
string
indexFiles
[]
string
shouldErr
bool
expectedFilePath
string
//retun value
expectedBoolValue
bool
//return value
}{
{
http
.
Dir
(
"./templates/testdata"
),
"/images/"
,
[]
string
{
"img.htm"
},
false
,
"/images/img.htm"
,
true
,
},
}
for
i
,
test
:=
range
tests
{
actualFilePath
,
actualBoolValue
:=
IndexFile
(
test
.
rootDir
,
test
.
fpath
,
test
.
indexFiles
)
if
actualBoolValue
==
true
&&
test
.
shouldErr
{
t
.
Errorf
(
"Test %d didn't error, but it should have"
,
i
)
}
else
if
actualBoolValue
!=
true
&&
!
test
.
shouldErr
{
t
.
Errorf
(
"Test %d errored, but it shouldn't have; got %s"
,
i
,
"Please Add a / at the end of fpath or the indexFiles doesnt exist"
)
}
if
actualFilePath
!=
test
.
expectedFilePath
{
t
.
Fatalf
(
"Test %d expected returned filepath to be %s, but got %s "
,
i
,
test
.
expectedFilePath
,
actualFilePath
)
}
if
actualBoolValue
!=
test
.
expectedBoolValue
{
t
.
Fatalf
(
"Test %d expected returned bool value to be %v, but got %v "
,
i
,
test
.
expectedBoolValue
,
actualBoolValue
)
}
}
}
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