testing

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertableJSON added in v1.15.0

type AssertableJSON interface {
	Count(key string, value int) AssertableJSON
	First(key string, callback func(AssertableJSON)) AssertableJSON
	Each(key string, callback func(AssertableJSON)) AssertableJSON
	Has(key string) AssertableJSON
	HasAll(keys []string) AssertableJSON
	HasAny(keys []string) AssertableJSON
	HasWithScope(key string, length int, callback func(AssertableJSON)) AssertableJSON
	Json() map[string]any
	Missing(key string) AssertableJSON
	MissingAll(keys []string) AssertableJSON
	Where(key string, value any) AssertableJSON
	WhereNot(key string, value any) AssertableJSON
}

type Database

type Database interface {
	DatabaseDriver
	// Migrate runs the database migrations.
	Migrate() error
	// Seed runs the database seeds.
	Seed(seeders ...seeder.Seeder) error
}

type DatabaseConfig added in v1.14.0

type DatabaseConfig struct {
	Host        string
	Port        int
	Database    string
	Username    string
	Password    string
	ContainerID string
}

type DatabaseDriver

type DatabaseDriver interface {
	// Build a database container, it doesn't wait for the database to be ready, the Ready method needs to be called if
	// you want to check the container status.
	Build() error
	// Config get database configuration.
	Config() DatabaseConfig
	// Database returns a new instance with a new database, the Build method needs to be called first.
	Database(name string) (DatabaseDriver, error)
	// Driver gets the database driver name.
	Driver() database.Driver
	// Fresh the database.
	Fresh() error
	// Image gets the database image.
	Image(image Image)
	// Ready checks if the database is ready, the Build method needs to be called first.
	Ready() error
	// Shutdown the database.
	Shutdown() error
}

type Docker

type Docker interface {
	// Database get a database connection instance.
	Database(connection ...string) (Database, error)
}

type Image

type Image struct {
	Env          []string
	ExposedPorts []string
	Repository   string
	Tag          string
}

type TestRequest added in v1.15.0

type TestRequest interface {
	Get(uri string) (TestResponse, error)
	Post(uri string, body io.Reader) (TestResponse, error)
	Put(uri string, body io.Reader) (TestResponse, error)
	Delete(uri string, body io.Reader) (TestResponse, error)
	Patch(uri string, body io.Reader) (TestResponse, error)
	Head(uri string) (TestResponse, error)
	Options(uri string) (TestResponse, error)

	Bind(value any) TestRequest
	FlushHeaders() TestRequest
	WithBasicAuth(username, password string) TestRequest
	WithContext(ctx context.Context) TestRequest
	WithCookies(cookies map[string]string) TestRequest
	WithCookie(key, value string) TestRequest
	WithHeader(key, value string) TestRequest
	WithHeaders(headers map[string]string) TestRequest
	WithoutHeader(key string) TestRequest
	WithToken(token string, ttype ...string) TestRequest
	WithoutToken() TestRequest
	WithSession(attributes map[string]any) TestRequest
}

type TestResponse added in v1.15.0

type TestResponse interface {
	Content() (string, error)
	Cookie(name string) *http.Cookie
	Cookies() []*http.Cookie
	Headers() http.Header
	IsServerError() bool
	IsSuccessful() bool
	Json() (map[string]any, error)
	Session() (map[string]any, error)

	AssertStatus(status int) TestResponse
	AssertOk() TestResponse
	AssertCreated() TestResponse
	AssertAccepted() TestResponse
	AssertNoContent(status ...int) TestResponse
	AssertMovedPermanently() TestResponse
	AssertFound() TestResponse
	AssertNotModified() TestResponse
	AssertPartialContent() TestResponse
	AssertTemporaryRedirect() TestResponse
	AssertBadRequest() TestResponse
	AssertUnauthorized() TestResponse
	AssertPaymentRequired() TestResponse
	AssertForbidden() TestResponse
	AssertNotFound() TestResponse
	AssertMethodNotAllowed() TestResponse
	AssertNotAcceptable() TestResponse
	AssertConflict() TestResponse
	AssertRequestTimeout() TestResponse
	AssertGone() TestResponse
	AssertUnsupportedMediaType() TestResponse
	AssertUnprocessableEntity() TestResponse
	AssertTooManyRequests() TestResponse
	AssertInternalServerError() TestResponse
	AssertServiceUnavailable() TestResponse
	AssertHeader(headerName, value string) TestResponse
	AssertHeaderMissing(string) TestResponse
	AssertCookie(name, value string) TestResponse
	AssertCookieExpired(string) TestResponse
	AssertCookieNotExpired(string) TestResponse
	AssertCookieMissing(string) TestResponse
	AssertSuccessful() TestResponse
	AssertServerError() TestResponse
	AssertDontSee([]string, ...bool) TestResponse
	AssertSee([]string, ...bool) TestResponse
	AssertSeeInOrder([]string, ...bool) TestResponse
	AssertJson(map[string]any) TestResponse
	AssertExactJson(map[string]any) TestResponse
	AssertJsonMissing(map[string]any) TestResponse
	AssertFluentJson(func(json AssertableJSON)) TestResponse
}

type Testing

type Testing interface {
	// Docker get the Docker instance.
	Docker() Docker
}

Jump to

Keyboard shortcuts

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