當前位置: 首頁>>代碼示例>>Golang>>正文


Golang htmltest.Curl函數代碼示例

本文整理匯總了Golang中github.com/rtfb/htmltest.Curl函數的典型用法代碼示例。如果您正苦於以下問題:Golang Curl函數的具體用法?Golang Curl怎麽用?Golang Curl使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Curl函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/rtfb/htmltest.Curl函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。