test

package
v1.12.8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: AGPL-3.0, AGPL-3.0-only Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const EnvMysql = "mysql"
View Source
const EnvRedis = "redis"

Variables

This section is empty.

Functions

func FxE2E

func FxE2E(t *testing.T) fx.Option

func GetGorm

func GetGorm(t TB) *gorm.DB

func GetWebApp

func GetWebApp(t TB, m Mock) *fiber.App

func MockAuthRepo

func MockAuthRepo(m domain.AuthRepo) fx.Option

func MockCache

func MockCache(mock cache.Generic) fx.Option

func MockCaptchaManager added in v0.12.4

func MockCaptchaManager(repo captcha.Manager) fx.Option

func MockCharacterRepo

func MockCharacterRepo(m domain.CharacterRepo) fx.Option

func MockEmptyCache

func MockEmptyCache() fx.Option

func MockEpisodeRepo

func MockEpisodeRepo(m domain.EpisodeRepo) fx.Option

func MockIndexRepo

func MockIndexRepo(repo domain.IndexRepo) fx.Option

func MockPersonRepo

func MockPersonRepo(m domain.PersonRepo) fx.Option

func MockRateLimiter added in v0.12.4

func MockRateLimiter(repo rate.Manager) fx.Option

func MockRevisionRepo added in v0.10.1

func MockRevisionRepo(repo domain.RevisionRepo) fx.Option

func MockSessionManager added in v0.12.4

func MockSessionManager(repo session.Manager) fx.Option

func MockSubjectRepo

func MockSubjectRepo(m domain.SubjectRepo) fx.Option

func MockUserRepo

func MockUserRepo(repo domain.UserRepo) fx.Option

func NopCache added in v0.12.4

func NopCache() cache.Generic

func RequireEnv

func RequireEnv(t TB, envs ...string)

RequireEnv

func TestGet(t *testing.T) {
  RequireEnv(t, test.EnvRedis, test.EnvMysql)
  ...
}

Types

type Mock

type Mock struct {
	SubjectRepo    domain.SubjectRepo
	PersonRepo     domain.PersonRepo
	CharacterRepo  domain.CharacterRepo
	AuthRepo       domain.AuthRepo
	EpisodeRepo    domain.EpisodeRepo
	UserRepo       domain.UserRepo
	IndexRepo      domain.IndexRepo
	RevisionRepo   domain.RevisionRepo
	CaptchaManager captcha.Manager
	SessionManager session.Manager
	Cache          cache.Generic
	RateLimiter    rate.Manager
	HTTPMock       *httpmock.MockTransport
}

type Request added in v0.11.1

type Request struct {
	Response interface{}

	HTTPVerb string

	Endpoint string
	HTTPBody []byte
	Cookies  []*http.Cookie
	// contains filtered or unexported fields
}

func New added in v0.11.1

func New(t *testing.T) *Request

func (*Request) Delete added in v0.11.1

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

func (*Request) Execute added in v0.11.1

func (r *Request) Execute(app *fiber.App, msTimeout ...int) *Response

func (*Request) Form added in v0.12.4

func (r *Request) Form(key, value string) *Request

func (*Request) Get added in v0.11.1

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

func (*Request) Header added in v0.11.1

func (r *Request) Header(key, value string) *Request

func (*Request) JSON added in v0.11.1

func (r *Request) JSON(v interface{}) *Request

func (*Request) Patch added in v0.11.1

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

func (*Request) Post added in v0.11.1

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

func (*Request) Put added in v0.11.1

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

func (*Request) Query added in v0.11.1

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

func (*Request) StdRequest added in v0.11.1

func (r *Request) StdRequest() *http.Request

type Response added in v0.11.1

type Response struct {
	Header     http.Header
	Body       []byte
	StatusCode int // e.g. 200
	// contains filtered or unexported fields
}

func (*Response) BodyString added in v0.11.1

func (r *Response) BodyString() string

func (*Response) ExpectCode added in v0.11.1

func (r *Response) ExpectCode(t int) *Response

func (*Response) JSON added in v0.11.1

func (r *Response) JSON(v interface{}) *Response

type TB added in v0.10.1

type TB interface {
	SkipNow()
	Helper()
	Errorf(format string, args ...interface{})
	FailNow()
	Fatal(args ...interface{})
}

Jump to

Keyboard shortcuts

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