本文整理汇总了Golang中github.com/rtfb/htmltest.Curl函数的典型用法代码示例。如果您正苦于以下问题:Golang Curl函数的具体用法?Golang Curl怎么用?Golang Curl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Curl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestHiddenPosts
func TestHiddenPosts(t *testing.T) {
var positiveTests = []struct {
url, content string
}{
{"hello1001", "Body"},
{"", "hello1001"},
{"archive", "hello1001"},
}
var negativeTests = []struct {
url, content string
}{
{"", "hello1001"},
{"archive", "hello1001"},
}
ensureLogin()
for _, i := range positiveTests {
html := htmltest.Curl(i.url)
mustContain(t, html, i.content)
}
doLogout()
for _, i := range negativeTests {
html := htmltest.Curl(i.url)
mustNotContain(t, html, i.content)
}
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:25,代码来源:rtfblog_test.go
示例2: TestHiddenPostAccess
func TestHiddenPostAccess(t *testing.T) {
ensureLogin()
html := htmltest.Curl("hello1001")
mustContain(t, html, "Body")
doLogout()
html = htmltest.Curl("hello1001")
mustContain(t, html, "Page Not Found")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:8,代码来源:rtfblog_test.go
示例3: TestRssFeed
func TestRssFeed(t *testing.T) {
xml := htmltest.Curl("feeds/rss.xml")
url := htmltest.PathToURL("")
mustContain(t, xml, fmt.Sprintf("<link>%s</link>", url))
mustContain(t, xml, "<title>Hi3</title>")
mustContain(t, xml, fmt.Sprintf("<link>%s/%s</link>", url, "hello3"))
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:7,代码来源:rtfblog_test.go
示例4: TestEditPost
func TestEditPost(t *testing.T) {
ensureLogin()
// test with non-hidden post
html := htmltest.Curl("edit_post?post=hello3")
mustContain(t, html, "Body3")
mustContain(t, html, "Hi3")
mustContain(t, html, "u3")
mustContain(t, html, "Delete!")
mustNotContain(t, html, "checked")
// now test with hidden post
html = htmltest.Curl("edit_post?post=hello1002")
mustContain(t, html, "Body1002")
mustContain(t, html, "Hi1002")
mustContain(t, html, "u1002")
mustContain(t, html, "Delete!")
mustContain(t, html, "checked")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:17,代码来源:rtfblog_test.go
示例5: TestTitleByTagGetsCalled
func TestTitleByTagGetsCalled(t *testing.T) {
defer testData.reset()
tag := "taaag"
html := htmltest.Curl("/tag/" + tag)
testData.expect(t, (*TestData).titlesByTag, tag)
mustContain(t, html, "Posts tagged ")
mustContain(t, html, tag)
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:8,代码来源:rtfblog_test.go
示例6: TestMainPageShowsCreateAuthorPage
func TestMainPageShowsCreateAuthorPage(t *testing.T) {
tmp := testAuthor
testAuthor = nil
html := htmltest.Curl("/")
mustContain(t, html, "New Password")
mustContain(t, html, "Confirm Password")
mustNotContain(t, html, "Old Password")
testAuthor = tmp
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:9,代码来源:rtfblog_test.go
示例7: TestEmptyDatasetGeneratesFriendlyError
func TestEmptyDatasetGeneratesFriendlyError(t *testing.T) {
tmpPosts := testPosts
testPosts = nil
defer func() {
testPosts = tmpPosts
}()
html := htmltest.Curl("")
mustContain(t, html, "No entries")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:9,代码来源:rtfblog_test.go
示例8: TestShowCaptcha
func TestShowCaptcha(t *testing.T) {
url := mkQueryURL("comment_submit", map[string]string{
"name": "joe",
"captcha": "",
"email": "snailmail",
"text": "cmmnt%20txt",
})
resp := mustUnmarshal(t, htmltest.Curl(url))
T{t}.failIf(resp["status"] != "showcaptcha", "No captcha box")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:10,代码来源:rtfblog_test.go
示例9: TestReturningCommenterSkipsCaptcha
func TestReturningCommenterSkipsCaptcha(t *testing.T) {
url := mkQueryURL("comment_submit", map[string]string{
"name": "N",
"captcha": "",
"email": "@",
"website": "w",
"text": "cmmnt%20txt",
})
resp := mustUnmarshal(t, htmltest.Curl(url))
T{t}.failIf(resp["status"] != "accepted", "Comment by returning commenter not accepted")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:11,代码来源:rtfblog_test.go
示例10: TestHiddenPostDoesNotAppearInRss
func TestHiddenPostDoesNotAppearInRss(t *testing.T) {
bak := testPosts
testPosts = make([]*Entry, 0)
testPosts = append(testPosts, mkTestEntry(1, false))
testPosts = append(testPosts, mkTestEntry(1000, true))
testPosts = append(testPosts, mkTestEntry(2, false))
ensureLogin()
xml := htmltest.Curl("feeds/rss.xml")
mustNotContain(t, xml, "hello1000")
testPosts = bak
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:11,代码来源:rtfblog_test.go
示例11: TestPagination
func TestPagination(t *testing.T) {
nodes := htmltest.Query(t, "page/2", "*", ".post-title")
T{t}.failIf(len(nodes) != PostsPerPage, "Not all posts have been rendered!")
if nodes[0].Attr[1].Val != "/hello6" {
t.Fatalf("Wrong post!")
}
if nodes[4].Attr[1].Val != "/hello10" {
t.Fatalf("Wrong post!")
}
html := htmltest.Curl("page/2")
mustContain(t, html, "<a href=\"/page/1\">1</a>\n2\n<a href=\"/page/3\">3</a>\n")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:12,代码来源:rtfblog_test.go
示例12: TestUndetectedLanguageCommentDismiss
func TestUndetectedLanguageCommentDismiss(t *testing.T) {
defer testData.reset()
url := mkQueryURL("comment_submit", map[string]string{
"name": "UnknownCommenter",
"captcha": "",
"email": "@",
"website": "w",
"text": "cmmnt%20txt",
"captcha-id": "666",
})
resp := mustUnmarshal(t, htmltest.Curl(url))
T{t}.failIf(resp["status"] != "rejected", "Comment with undetected language not rejected")
testData.expect(t, (*TestData).postID, "")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:14,代码来源:rtfblog_test.go
示例13: TestCorrectCaptchaReply
func TestCorrectCaptchaReply(t *testing.T) {
defer testData.reset()
deck := NewDeck()
deck.SetNextTask(0)
task := deck.NextTask()
url := mkQueryURL("comment_submit", map[string]string{
"name": "UnknownCommenter",
"captcha": task.Answer,
"email": "@",
"website": "w",
"text": "cmmnt%20txt",
"captcha-id": task.ID,
})
resp := mustUnmarshal(t, htmltest.Curl(url))
T{t}.failIf(resp["status"] != "accepted", "Comment with correct captcha reply not accepted")
testData.expectChain(t, []CallSpec{{(*TestData).postID, ""},
{(*TestData).insertCommenter, "UnknownCommenter"}})
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:18,代码来源:rtfblog_test.go
示例14: TestMainPage
func TestMainPage(t *testing.T) {
var simpleTests = []struct {
url string
out string
}{
{"", "container"},
{"", "header"},
{"", "subheader"},
{"", "content"},
{"", "sidebar"},
{"", "footer"},
{"", "Ribs"},
{"", "utf-8"},
{"", "gopher.png"},
{"", "vim_created.png"},
}
for _, test := range simpleTests {
mustContain(t, htmltest.Curl(test.url), test.out)
}
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:20,代码来源:rtfblog_test.go
示例15: TestDetectedLtLanguageCommentApprove
func TestDetectedLtLanguageCommentApprove(t *testing.T) {
defer testData.reset()
temp := langDetector
defer func() {
langDetector = temp
}()
langDetector = LTLangDetector{}
url := mkQueryURL("comment_submit", map[string]string{
"name": "UnknownCommenter",
"captcha": "",
"email": "@",
"website": "w",
"text": "cmmnt%20txt",
})
resp := mustUnmarshal(t, htmltest.Curl(url))
T{t}.failIf(resp["status"] != "accepted", "Comment w/ detected language 'lt' not accepted")
testData.expectChain(t, []CallSpec{{(*TestData).postID, ""},
{(*TestData).postID, ""},
{(*TestData).postID, ""},
{(*TestData).insertCommenter, "UnknownCommenter"}})
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:21,代码来源:rtfblog_test.go
示例16: TestNonAdminCantAccessAdminPages
func TestNonAdminCantAccessAdminPages(t *testing.T) {
doLogout()
urls := []string{
"all_comments",
"admin",
"edit_post",
"load_comments",
"delete_comment",
"delete_post",
}
for _, u := range urls {
html := htmltest.Curl(u)
mustContain(t, html, "Verboten")
}
postUrls := []string{
"moderate_comment",
"submit_post",
"upload_images",
}
for _, u := range postUrls {
html := htmltest.CurlPost(u)
mustContain(t, html, "Verboten")
}
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:24,代码来源:rtfblog_test.go
示例17: TestInvalidPageDefaultsToPageOne
func TestInvalidPageDefaultsToPageOne(t *testing.T) {
page1 := htmltest.Curl("/page/1")
pageFoo := htmltest.Curl("/page/foo")
T{t}.failIf(page1 != pageFoo, "Invalid page did not produce /page/1")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:5,代码来源:rtfblog_test.go
示例18: TestAdminPageHasEditAuthorButton
func TestAdminPageHasEditAuthorButton(t *testing.T) {
mustContain(t, htmltest.Curl("/admin"), "Edit Author Profile")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:3,代码来源:rtfblog_test.go
示例19: TestLoadComments
func TestLoadComments(t *testing.T) {
ensureLogin()
json := htmltest.Curl("/load_comments?post=hello1")
mustContain(t, json, `"Comments":[{"Name":"N","Email":"@"`)
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:5,代码来源:rtfblog_test.go
示例20: TestRobotsTxtGetsServed
func TestRobotsTxtGetsServed(t *testing.T) {
robots := htmltest.Curl("robots.txt")
mustContain(t, robots, "Disallow")
}
开发者ID:rtfb,项目名称:rtfblog,代码行数:4,代码来源:rtfblog_test.go
注:本文中的github.com/rtfb/htmltest.Curl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论