serverify

package module
v0.0.0-...-4478b2b Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-serverify

go-serverify is Go client library for serverify.

Installation

go get github.com/autopp/go-serverify

Usage

import (
	"testing"

	"github.com/autopp/go-serverify"
)

func TestExample(t *testing.T) {
	s := serverify.New("http://localhost:8080")

	// Create session for this test
	session, _ := s.CreateSession("test_session")
	defer session.Delete()

	// Act with serverify
	app := MyApplication(MyConfig { endpoint: session.BaseURL() })
	...

	// Assert occured request
	logs, _ := session.Logs()
	...
}

License

Apache-2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	StatusCode     int
	ServerifyError struct {
		Message string
	}
}

func (Error) Error

func (e Error) Error() string

type Log

type Log struct {
	Method      string            `json:"method"`
	Headers     map[string]string `json:"headers"`
	Path        string            `json:"path"`
	Query       map[string]string `json:"query"`
	Body        string            `json:"body"`
	RequestedAt time.Time         `json:"requestedAt"`
}

Log represents the request log

type Logs

type Logs struct {
	Histories []Log `json:"histories"`
}

Logs represents request logs of the session

type Serverify

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

Serverify is top level struct to interact with Serverify API

func New

func New(baseURL string) *Serverify

New create a Serverify instance with the given base URL

func (*Serverify) CreateSession

func (s *Serverify) CreateSession(name string) (*Session, error)

CreateSession creates new session with the given name

type Session

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

Session is created by Serverify.CreateSession

func (*Session) BaseURL

func (s *Session) BaseURL() string

BaseURL returns the base URL of mock endpoint for this session

func (*Session) Delete

func (s *Session) Delete() error

Delete deletes the session

func (*Session) Logs

func (s *Session) Logs() (*Logs, error)

Logs returns request logs of the session

func (*Session) Name

func (s *Session) Name() string

Name returns name of the session

Jump to

Keyboard shortcuts

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