This repository has been archived on 2022-08-17. You can view files and clone it, but cannot push or open issues or pull requests.
dex/vendor/github.com/mbanzon/simplehttp/payload_test.go

39 lines
763 B
Go
Raw Normal View History

2016-04-09 00:26:29 +05:30
package simplehttp
import (
"bytes"
"github.com/mbanzon/callbackenv"
"io/ioutil"
"testing"
)
const (
FILE_ENV = "SIMPLEHTTP_TEST_FILE"
)
func TestFormDataPayloadPost(t *testing.T) {
payload := NewFormDataPayload()
payload.AddValue("key", "value")
buf := &bytes.Buffer{}
buf.Write([]byte("testing testing testing"))
rc := ioutil.NopCloser(buf)
payload.AddReadCloser("foo", "bar", rc)
callbackenv.RequireEnv(FILE_ENV,
func(file string) {
payload.AddFile("file", file)
}, nil)
request := NewHTTPRequest(dummyurl)
request.MakePostRequest(payload)
}
func TestUrlEncodedPayloadPost(t *testing.T) {
payload := NewUrlEncodedPayload()
payload.AddValue("key", "value")
request := NewHTTPRequest(dummyurl)
request.MakePostRequest(payload)
}