test

package
v0.0.0-...-471d7c0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHelper

type ClientHelper struct {
	Client *client.Client
	User   *models.User
	// contains filtered or unexported fields
}

ClientHelper is a Titan Client wrapper for testing. All the functions are wrapped with proper test runner error logging.

func NewClientHelper

func NewClientHelper(t *testing.T, addr string) *ClientHelper

NewClientHelper creates a new client helper object.

func (*ClientHelper) AsUser

func (ch *ClientHelper) AsUser(u *models.User) *ClientHelper

AsUser attaches given user's client certificate and private key to the connection.

func (*ClientHelper) CloseWait

func (ch *ClientHelper) CloseWait()

CloseWait closes a connection. Waits till all the goroutines handling messages quit.

func (*ClientHelper) Connect

func (ch *ClientHelper) Connect() *ClientHelper

Connect connects to a server.

func (*ClientHelper) EchoSync

func (ch *ClientHelper) EchoSync(message string) *ClientHelper

EchoSync is synchronous version of Client.Echo method.

func (*ClientHelper) GetMessagesWait

func (ch *ClientHelper) GetMessagesWait() []models.Message

GetMessagesWait waits for and returns incoming messages. If no message arrives within the timeout, test fails.

func (*ClientHelper) GoogleAuthSync

func (ch *ClientHelper) GoogleAuthSync(oauthToken string) *ClientHelper

GoogleAuthSync is synchronous version of Client.GoogleAuth method. Google OAuth token is exchanged for a JWT token. If any user was assigned with AsUser, the new JWT token is stored in the user's profile.

func (*ClientHelper) JWTAuthSync

func (ch *ClientHelper) JWTAuthSync() *ClientHelper

JWTAuthSync does JWT authentication with the token belonging the the user assigned with AsUser method. This method runs synchronously and blocks until authentication response is received (or connection is closed by server).

func (*ClientHelper) SendMessagesSync

func (ch *ClientHelper) SendMessagesSync(messages []models.Message) *ClientHelper

SendMessagesSync is synchronous version of Client.SendMessages method.

type ServerHelper

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

ServerHelper is a titan.Server wrapper for testing. All the functions are wrapped with proper test runner error logging.

func NewServerHelper

func NewServerHelper(t *testing.T) *ServerHelper

NewServerHelper creates a new server helper object. Titan server instance is initialized and ready to accept connection after this function return.

func (*ServerHelper) CloseWait

func (sh *ServerHelper) CloseWait()

CloseWait closes the server and wait for all request/conn goroutines to exit.

func (*ServerHelper) GetClientHelper

func (sh *ServerHelper) GetClientHelper() *ClientHelper

GetClientHelper creates and returns a ClientHelper that is connected to this server instance.

func (*ServerHelper) ListenAndServe

func (sh *ServerHelper) ListenAndServe() *ServerHelper

ListenAndServe starts the server.

Jump to

Keyboard shortcuts

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