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
2b7ec1b0
Commit
2b7ec1b0
authored
Jul 11, 2015
by
Karthic Rao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete test coverage for config/setup/markdown.go
parent
d3c22937
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
config/setup/markdown_test.go
config/setup/markdown_test.go
+55
-0
No files found.
config/setup/markdown_test.go
View file @
2b7ec1b0
package
setup
import
(
"fmt"
"github.com/mholt/caddy/middleware/markdown"
"testing"
)
...
...
@@ -29,5 +30,59 @@ func TestMarkdown(t *testing.T) {
if
myHandler
.
Configs
[
0
]
.
PathScope
!=
"/blog"
{
t
.
Errorf
(
"Expected /blog as the Path Scope"
)
}
if
fmt
.
Sprint
(
myHandler
.
Configs
[
0
]
.
Extensions
)
!=
fmt
.
Sprint
([]
string
{
".md"
})
{
t
.
Errorf
(
"Expected .md as the Default Extension"
)
}
}
func
TestMarkdownParse
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
inputMarkdownConfig
string
shouldErr
bool
expectedMarkdownConfig
[]
markdown
.
Config
}{
{
`markdown /blog {
ext .md .txt
css /resources/css/blog.css
js /resources/js/blog.js
}`
,
false
,
[]
markdown
.
Config
{{
PathScope
:
"/blog"
,
Extensions
:
[]
string
{
".md"
,
".txt"
},
Styles
:
[]
string
{
"/resources/css/blog.css"
},
Scripts
:
[]
string
{
"/resources/js/blog.js"
},
}}},
}
for
i
,
test
:=
range
tests
{
c
:=
NewTestController
(
test
.
inputMarkdownConfig
)
actualMarkdownConfigs
,
err
:=
markdownParse
(
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
(
actualMarkdownConfigs
)
!=
len
(
test
.
expectedMarkdownConfig
)
{
t
.
Fatalf
(
"Test %d expected %d no of WebSocket configs, but got %d "
,
i
,
len
(
test
.
expectedMarkdownConfig
),
len
(
actualMarkdownConfigs
))
}
for
j
,
actualMarkdownConfig
:=
range
actualMarkdownConfigs
{
if
actualMarkdownConfig
.
PathScope
!=
test
.
expectedMarkdownConfig
[
j
]
.
PathScope
{
t
.
Errorf
(
"Test %d expected %dth Markdown PathScope to be %s , but got %s"
,
i
,
j
,
test
.
expectedMarkdownConfig
[
j
]
.
PathScope
,
actualMarkdownConfig
.
PathScope
)
}
if
fmt
.
Sprint
(
actualMarkdownConfig
.
Styles
)
!=
fmt
.
Sprint
(
test
.
expectedMarkdownConfig
[
j
]
.
Styles
)
{
t
.
Errorf
(
"Test %d expected %dth Markdown Config Styles to be %s , but got %s"
,
i
,
j
,
fmt
.
Sprint
(
test
.
expectedMarkdownConfig
[
j
]
.
Styles
),
fmt
.
Sprint
(
actualMarkdownConfig
.
Styles
))
}
if
fmt
.
Sprint
(
actualMarkdownConfig
.
Scripts
)
!=
fmt
.
Sprint
(
test
.
expectedMarkdownConfig
[
j
]
.
Scripts
)
{
t
.
Errorf
(
"Test %d expected %dth Markdown Config Scripts to be %s , but got %s"
,
i
,
j
,
fmt
.
Sprint
(
test
.
expectedMarkdownConfig
[
j
]
.
Scripts
),
fmt
.
Sprint
(
actualMarkdownConfig
.
Scripts
))
}
}
}
}
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