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 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
Click to show internal directories.
Click to hide internal directories.