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
fd14f257
Commit
fd14f257
authored
Dec 02, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
markdown: Add (currently failing) test for empty body
parent
d044e497
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
22 deletions
+47
-22
middleware/markdown/metadata_test.go
middleware/markdown/metadata_test.go
+47
-22
No files found.
middleware/markdown/metadata_test.go
View file @
fd14f257
...
...
@@ -14,8 +14,7 @@ func check(t *testing.T, err error) {
}
}
func
TestParsers
(
t
*
testing
.
T
)
{
var
TOML
=
[
4
]
string
{
`
var
TOML
=
[
5
]
string
{
`
title = "A title"
template = "default"
name = "value"
...
...
@@ -33,9 +32,15 @@ template = "default"
name = "value"
`
,
`title = "A title" template = "default" [variables] name = "value"`
,
}
`+++
title = "A title"
template = "default"
name = "value"
+++
`
,
}
var
YAML
=
[
4
]
string
{
`
var
YAML
=
[
5
]
string
{
`
title : A title
template : default
name : value
...
...
@@ -53,11 +58,18 @@ template : default
name : value
`
,
`title : A title template : default variables : name : value`
,
}
var
JSON
=
[
4
]
string
{
`
"title" : "A title",
"template" : "default",
"name" : "value"
`---
title : A title
template : default
name : value
---
`
,
}
var
JSON
=
[
5
]
string
{
`
"title" : "A title",
"template" : "default",
"name" : "value"
`
,
`{
"title" : "A title",
...
...
@@ -73,13 +85,21 @@ Page content
"name" : "value"
`
,
`
{
{
"title" : "A title",
{
"title" :
:
"A title",
"template" : "default",
"name" : "value"
}
`
,
}
`{
"title" : "A title",
"template" : "default",
"name" : "value"
}
`
,
}
func
TestParsers
(
t
*
testing
.
T
)
{
expected
:=
Metadata
{
Title
:
"A title"
,
Template
:
"default"
,
...
...
@@ -106,7 +126,7 @@ Page content
data
:=
[]
struct
{
parser
MetadataParser
testData
[
4
]
string
testData
[
5
]
string
name
string
}{
{
&
JSONMetadataParser
{
metadata
:
Metadata
{
Variables
:
make
(
map
[
string
]
string
)}},
JSON
,
"json"
},
...
...
@@ -149,6 +169,11 @@ Page content
if
md
,
err
=
v
.
parser
.
Parse
([]
byte
(
v
.
testData
[
3
]));
err
==
nil
{
t
.
Fatalf
(
"Expected error for invalid metadata for %v"
,
v
.
name
)
}
// front matter but no body
if
md
,
err
=
v
.
parser
.
Parse
([]
byte
(
v
.
testData
[
4
]));
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error for valid metadata but no body for %v"
,
v
.
name
)
}
}
}
...
...
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