test

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyEquals

func BodyEquals(t assert.TestingT, obj interface{}, recorder *httptest.ResponseRecorder)

BodyEquals asserts the content from the response recorder with the encoded json of the provided instance.

func JSONEquals

func JSONEquals(t assert.TestingT, obj interface{}, expected string)

JSONEquals asserts the content of the string with the encoded json of the provided instance.

func WithUser

func WithUser(ctx *gin.Context, userID uint)

WithUser fake an authentication for testing.

Types

type AppClientBuilder

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

AppClientBuilder has helper methods to create applications and clients.

func (*AppClientBuilder) App

func (ab *AppClientBuilder) App(id uint) *MessageBuilder

App creates an application and returns a message builder.

func (*AppClientBuilder) AppWithToken

func (ab *AppClientBuilder) AppWithToken(id uint, token string) *MessageBuilder

AppWithToken creates an application with a token and returns a message builder.

func (*AppClientBuilder) AppWithTokenAndName added in v1.2.0

func (ab *AppClientBuilder) AppWithTokenAndName(id uint, token, name string) *MessageBuilder

AppWithTokenAndName creates an application with a token and name and returns a message builder.

func (*AppClientBuilder) Client

func (ab *AppClientBuilder) Client(id uint) *AppClientBuilder

Client creates a client and returns itself.

func (*AppClientBuilder) ClientWithToken

func (ab *AppClientBuilder) ClientWithToken(id uint, token string) *AppClientBuilder

ClientWithToken creates a client with a token and returns itself.

func (*AppClientBuilder) NewAppWithToken

func (ab *AppClientBuilder) NewAppWithToken(id uint, token string) *model.Application

NewAppWithToken creates an application with a token and returns the app.

func (*AppClientBuilder) NewAppWithTokenAndName added in v1.2.0

func (ab *AppClientBuilder) NewAppWithTokenAndName(id uint, token, name string) *model.Application

NewAppWithTokenAndName creates an application with a token and name and returns the app.

func (*AppClientBuilder) NewClientWithToken

func (ab *AppClientBuilder) NewClientWithToken(id uint, token string) *model.Client

NewClientWithToken creates a client with a token and returns the client.

type Database

type Database struct {
	*database.GormDatabase
	// contains filtered or unexported fields
}

Database is the wrapper for the gorm database with sleek helper methods.

func NewDB

func NewDB(t *testing.T) *Database

NewDB creates a new test db instance.

func NewDBWithDefaultUser

func NewDBWithDefaultUser(t *testing.T) *Database

NewDBWithDefaultUser creates a new test db instance with the default user.

func (*Database) AssertAppExist

func (d *Database) AssertAppExist(id uint)

AssertAppExist asserts that the app does exist.

func (*Database) AssertAppNotExist

func (d *Database) AssertAppNotExist(id uint)

AssertAppNotExist asserts that the app does not exist.

func (*Database) AssertClientExist

func (d *Database) AssertClientExist(id uint)

AssertClientExist asserts that the client does exist.

func (*Database) AssertClientNotExist

func (d *Database) AssertClientNotExist(id uint)

AssertClientNotExist asserts that the client does not exist.

func (*Database) AssertMessageExist

func (d *Database) AssertMessageExist(id uint)

AssertMessageExist asserts that the message does exist.

func (*Database) AssertMessageNotExist

func (d *Database) AssertMessageNotExist(ids ...uint)

AssertMessageNotExist asserts that the messages does not exist.

func (*Database) AssertUserExist

func (d *Database) AssertUserExist(id uint)

AssertUserExist asserts that the user does exist.

func (*Database) AssertUserNotExist

func (d *Database) AssertUserNotExist(id uint)

AssertUserNotExist asserts that the user does not exist.

func (*Database) NewUser

func (d *Database) NewUser(id uint) *model.User

NewUser creates a user and returns the user.

func (*Database) NewUserWithName

func (d *Database) NewUserWithName(id uint, name string) *model.User

NewUserWithName creates a user with a name and returns the user.

func (*Database) User

func (d *Database) User(id uint) *AppClientBuilder

User creates a user and returns a builder for applications and clients.

type MessageBuilder

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

MessageBuilder has helper methods to create messages.

func (*MessageBuilder) Message

func (mb *MessageBuilder) Message(id uint) *MessageBuilder

Message creates a message and returns itself

func (*MessageBuilder) NewMessage

func (mb *MessageBuilder) NewMessage(id uint) model.Message

NewMessage creates a message and returns the message.

Jump to

Keyboard shortcuts

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