supertest

package module
v0.0.0-...-0bfd4c0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2014 License: MIT Imports: 9 Imported by: 0

README

Build Status

go-supertest

HTTP assertions made easy for Go via goreq

We love nodejs supertest module and we wanted something like that for Go.

Why?

Because we want to keep HTTP testing in Go plain simple.

Example

import (
        . "github.com/franela/goblin"
        . "github.com/franela/go-supertest"
)

func MyTest(t *testing.T) {
  g := Goblin(t)

  g.Describe("GET /", function() {
    g.It("Should respond 200", function(done Done) {
      NewRequest("http://example.com").
        Get("/").
        Expect(200, done)
    })
  })
}

API

.expect(status[, func])

Assert response status code.

.expect(status, body[, fn])

Assert response status code and body.

Notes

Inspired by supertest.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

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

func NewRequest

func NewRequest(base string) *Request

func (*Request) Delete

func (r *Request) Delete(path string) *Request

func (*Request) Expect

func (r *Request) Expect(code int, args ...interface{}) error

func (*Request) Get

func (r *Request) Get(path string) *Request

func (*Request) Head

func (r *Request) Head(path string) *Request

func (*Request) Options

func (r *Request) Options(path string) *Request

func (*Request) Patch

func (r *Request) Patch(path string) *Request

func (*Request) Post

func (r *Request) Post(path string) *Request

func (*Request) Put

func (r *Request) Put(path string) *Request

func (*Request) Query

func (r *Request) Query(name, value string) *Request

func (*Request) Send

func (r *Request) Send(body interface{}) *Request

func (*Request) Set

func (r *Request) Set(name, value string) *Request

Jump to

Keyboard shortcuts

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