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/shorthand_test.go

105 lines
1.6 KiB
Go
Raw Normal View History

2016-04-09 00:26:29 +05:30
package simplehttp
import (
"testing"
)
func TestShorthandFailingPayload(t *testing.T) {
Request{
Url: dummyurl,
Data: nil,
}.Post()
}
func TestShorthandGet(t *testing.T) {
code, _, err := Request{
Url: dummyurl,
UserAgent: "simplehttp go test",
}.Get()
if code == -1 || err != nil {
t.Fail()
}
}
func TestShorthandPost(t *testing.T) {
code, _, err := Request{
Url: dummyurl,
Data: []byte("foobar"),
UserAgent: "simplehttp go test",
Authentication: BasicAuthentication{
User: "test",
Password: "test",
},
}.Post()
if code == -1 || err != nil {
t.Fail()
}
}
func TestShorthandPut(t *testing.T) {
code, _, err := Request{
Url: dummyurl,
Data: []byte("foobar"),
UserAgent: "simplehttp go test",
}.Put()
if code == -1 || err != nil {
t.Fail()
}
}
func TestShorthandDelete(t *testing.T) {
code, _, err := Request{
Url: dummyurl,
UserAgent: "simplehttp go test",
}.Delete()
if code == -1 || err != nil {
t.Fail()
}
}
func TestFailingShorthandGet(t *testing.T) {
code, _, err := Request{
Url: invalidurl,
}.Get()
if code != -1 || err == nil {
t.Fail()
}
}
func TestFailingShorthandPost(t *testing.T) {
code, _, err := Request{
Url: invalidurl,
Data: []byte("foobar"),
}.Post()
if code != -1 || err == nil {
t.Fail()
}
}
func TestFailingShorthandPut(t *testing.T) {
code, _, err := Request{
Url: invalidurl,
Data: []byte("foobar"),
}.Put()
if code != -1 || err == nil {
t.Fail()
}
}
func TestFailingShorthandDelete(t *testing.T) {
code, _, err := Request{
Url: invalidurl,
}.Delete()
if code != -1 || err == nil {
t.Fail()
}
}