Exemplo n.º 1
0
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"))
}
Exemplo n.º 2
0
// Creates a new file upload http request with optional extra params
func mkFakeFileUploadRequest(uri string, params map[string]string, paramName, fileName, contents string) (*http.Request, error) {
	body := &bytes.Buffer{}
	writer := multipart.NewWriter(body)
	part, err := writer.CreateFormFile(paramName, fileName)
	if err != nil {
		return nil, err
	}
	_, err = io.Copy(part, strings.NewReader(contents))
	for key, val := range params {
		_ = writer.WriteField(key, val)
	}
	err = writer.Close()
	if err != nil {
		return nil, err
	}
	req, err := http.NewRequest("POST", htmltest.PathToURL(uri), body)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Content-Type", writer.FormDataContentType())
	return req, nil
}