supertest

package module
v0.0.0-...-805e30f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 9 Imported by: 0

README

Build Status Go Docs

httptest

Examples

import . "github.com/haoxins/httptest"
import "testing"

func TestGet1(t *testing.T) {
  Request("http://httpbin.org", t).
    Get("/get").
    Query("name=test").
    Expect(200).
    Expect("Content-Type", "application/json").
    End()
}

func TestGet2(t *testing.T) {
  Request("http://example.com").
    Get("/hello").
    Expect(200).
    Expect("Content-Type", "application/json").
    Expect(`{"name":"hello"}`).
    // or
    // Expect(map[string]string{"name": "hello"}).
    End()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func Request

func Request(host string, ts ...*testing.T) *Agent

func (*Agent) AddCookie

func (a *Agent) AddCookie(cookie *http.Cookie) *Agent

func (*Agent) AddCookies

func (a *Agent) AddCookies(cookies []*http.Cookie) *Agent

func (*Agent) Delete

func (a *Agent) Delete(path string) *Agent

func (*Agent) End

func (a *Agent) End(cbs ...func(response *resty.Response, bodyString string, err error))

func (*Agent) Expect

func (a *Agent) Expect(args ...interface{}) *Agent

func (*Agent) Get

func (a *Agent) Get(path string) *Agent

func (*Agent) Head

func (a *Agent) Head(path string) *Agent

func (*Agent) Options

func (a *Agent) Options(path string) *Agent

func (*Agent) Patch

func (a *Agent) Patch(path string) *Agent

func (*Agent) Post

func (a *Agent) Post(path string, body string) *Agent

func (*Agent) Put

func (a *Agent) Put(path string, body string) *Agent

func (*Agent) Query

func (a *Agent) Query(q map[string]string) *Agent

func (*Agent) Set

func (a *Agent) Set(param, value string) *Agent

func (*Agent) SetBasicAuth

func (a *Agent) SetBasicAuth(username, password string) *Agent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL