Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10494309
posts_test.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
posts_test.go
View Options
/*
* Copyright © 2020-2021 Musing Studio LLC.
*
* This file is part of WriteFreely.
*
* WriteFreely is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, included
* in the LICENSE file in this source code package.
*/
package
writefreely_test
import
(
"testing"
"github.com/guregu/null/zero"
"github.com/stretchr/testify/assert"
"github.com/writefreely/writefreely"
)
func
TestPostSummary
(
t
*
testing
.
T
)
{
testCases
:=
map
[
string
]
struct
{
given
writefreely
.
Post
expected
string
}{
"no special chars"
:
{
givenPost
(
"Content."
),
"Content."
},
"HTML content"
:
{
givenPost
(
"Content <p>with a</p> paragraph."
),
"Content with a paragraph."
},
"content with escaped char"
:
{
givenPost
(
"Content's all OK."
),
"Content's all OK."
},
"multiline content"
:
{
givenPost
(
`Content
in
multiple
lines.`
),
"Content in multiple lines."
},
}
for
name
,
test
:=
range
testCases
{
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
actual
:=
test
.
given
.
Summary
()
assert
.
Equal
(
t
,
test
.
expected
,
actual
)
})
}
}
func
givenPost
(
content
string
)
writefreely
.
Post
{
return
writefreely
.
Post
{
Title
:
zero
.
StringFrom
(
"Title"
),
Content
:
content
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 6, 10:54 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3168334
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment