go-apiclient-tester

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: MIT

README

��# go-apiclient-tester GoDoc-Postman GoDoc-Tester

A simple, easy to use library to test HTTP based API clients.

Main use-case for this library is to be able to use Postman Collections for unit testing. Create requests/examples in Postman; then export as "Collection v2.1" format. It can verify that requests from your API client match to the ones in the collection and respond with the recorded response.

Example

    package awesomeclient

    import (
        "testing"
        "github.com/finarfin/go-apiclient-tester/postman"
        "github.com/finarfin/go-apiclient-tester/tester"
        "github.com/stretchr/testify/assert"
    )

    func TestUserCreateSuccess(t *testing.T) {
        tester, err := postman.NewTester("testdata/collection.json")        
        if err != nil {
            t.Fatal(err)
        }
        defer tester.Close()
        tester.Setup("user", "create_success")

        _, err = c.CreateUser("user1")
        if err != nil {
            t.Fatal(err)
        }
    }

    func TestUserCreateFailure(t *testing.T) {
        tester, err := postman.NewTester("testdata/collection.json")
        if err != nil {
            t.Fatal(err)
        }
        defer tester.Close()
        tester.Setup("user", "create_failure")

        _, err = c.CreateUser("user1")
        assert.Error(t, err)
    }

License

MIT

Directories

Path Synopsis
Package postman implements a library that configures tester.Tester from Postman collections.
Package postman implements a library that configures tester.Tester from Postman collections.
Package tester implements a library that makes testing HTTP based API clients easier.
Package tester implements a library that makes testing HTTP based API clients easier.

Jump to

Keyboard shortcuts

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