testutils

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C2S_Test_MessageType = 9000
)

message types

Variables

This section is empty.

Functions

func CreateMockIdentityPayload

func CreateMockIdentityPayload(playerId int) *pb_base.IdentityPayload

creates mock identity payload for testing purposes

func EstablishWsConnection added in v0.1.12

func EstablishWsConnection(t *testing.T, port int) (*websocket.Conn, error)

func ResetSQLiteTestDB added in v0.1.13

func ResetSQLiteTestDB() error

func SendMessage

func SendMessage[T proto.Message](ws *websocket.Conn, messageType int, m server.KeystoneTx[T]) error

func Server

func Server(t *testing.T, mode server.GameMode, websocketPort int, schemaToTableAccessors map[interface{}]*state.TableBaseAccessor[any]) (*gin.Engine, *server.EngineCtx, *sql.DB, error)

TODO: refactor http to also be started inside here

func SetupMySQLTestDB added in v0.1.13

func SetupMySQLTestDB(t *testing.T, testGameID string, deleteTables bool, accessors map[interface{}]*state.TableBaseAccessor[any]) (*gamedb.MySQLSaveStateHandler, *gamedb.MySQLSaveTransactionHandler, *sql.DB)

func SetupSQLiteTestDB added in v0.1.13

func SetupSQLiteTestDB(t *testing.T, testGameID string, deleteTables bool, accessors map[interface{}]*state.TableBaseAccessor[any]) (*gamedb.MySQLSaveStateHandler, *gamedb.MySQLSaveTransactionHandler, *sql.DB)

setup local sqlite test db

func SkipTestIfShort added in v0.1.12

func SkipTestIfShort(t *testing.T)

func SocketRequestRouter

func SocketRequestRouter(ctx *server.EngineCtx, requestMsg *server.NetworkMessage, socketConnection *websocket.Conn)

the websocket router routes incoming requests based on protobuf types

func VerifyIdentity

func VerifyIdentity[T IVerifyIdentity]() server.IMiddleware[T]

verifies that a request has a valid jwt identity payload

Types

type IVerifyIdentity

type IVerifyIdentity interface {
	GetIdentityPayload() *pb_base.IdentityPayload
}

we assume that all incoming requests have an identity payload

type MockErrorHandler

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

func NewMockErrorHandler

func NewMockErrorHandler() *MockErrorHandler

func (*MockErrorHandler) ErrorCount

func (m *MockErrorHandler) ErrorCount() int

func (*MockErrorHandler) FormatMessage

func (m *MockErrorHandler) FormatMessage(id int, errorMessage string) *server.NetworkMessage

func (*MockErrorHandler) LastError

func (m *MockErrorHandler) LastError() string

type PortManager

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

func NewPortManager

func NewPortManager() *PortManager

func (*PortManager) GetPort

func (p *PortManager) GetPort() int

Jump to

Keyboard shortcuts

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