webtest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package webtest implements an easy way to write test for web modules

Index

Constants

This section is empty.

Variables

View Source
var (
	// DBConnection - url to database on setting up default WebService for webtest
	DBConnection = "postgresql://root:root@localhost:26257/defaultdb?sslmode=disable"
)

Functions

This section is empty.

Types

type Login

type Login struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Login Request format (maybe just internal usage)

type Option

type Option struct {
	ModuleLoader web.ModuleRegisterFunc
	Database     bool
	DBReRun      bool
	DBSetup      func(db *database.Database)
	Mailer       bool
	Logger       *zap.Logger
}

Option to configure TestServer

func (Option) New

func (option Option) New() (*TestServer, error)

New allows to configure WebService for testing

type TestServer

type TestServer struct {
	DB    *database.Database
	Mails chan *mailer.TestingMail
	Close func()

	WS *web.Service
	// contains filtered or unexported fields
}

TestServer - to run it without listen an server

func New

func New(modules web.ModuleRegisterFunc) (*TestServer, error)

New starts WebService for testing

func NewWithDBSetup

func NewWithDBSetup(modules web.ModuleRegisterFunc, dbCall func(db *database.Database)) (*TestServer, error)

NewWithDBSetup allows to reconfigure before ReRun the database - e.g. for adding Migration-Steps

func (*TestServer) DatabaseForget

func (s *TestServer) DatabaseForget()

DatabaseForget to run a test without a database

func (*TestServer) Login

func (s *TestServer) Login(login Login) error

Login to API by send request

func (*TestServer) Request

func (s *TestServer) Request(method, url string, body interface{}, expectCode int, jsonObj interface{}) error

Request sends a request to webtest WebService

func (*TestServer) TestLogin

func (s *TestServer) TestLogin() error

TestLogin to API by default login data

Jump to

Keyboard shortcuts

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