framework

package
v0.0.0-...-f9bed8c Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Client

type Client struct {
	User  *domain.User
	Log   *slog.Logger
	Token string

	FW  *Framework
	Cli *socketio.Client
}

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateGame

func (c *Client) CreateGame() (*domain.Game, error)

func (*Client) Emit

func (c *Client) Emit(ev Event)

func (*Client) JoinGame

func (c *Client) JoinGame(game *domain.Game)

func (*Client) MustCreateGame

func (c *Client) MustCreateGame() *domain.Game

func (*Client) On

func (c *Client) On(event string, f HandlerFunc)

func (*Client) Setup

func (c *Client) Setup(toRecord map[string]struct{})

type Event

type Event interface {
	Event() string
}

type Framework

type Framework struct {
	Cfg *config.Config
	DB  *pgxpool.Pool
	Log *slog.Logger

	HTTPCli *http.Client
	APIHost string
	SIOHost string

	Session *session.Session
}

func MustInit

func MustInit() *Framework

func (*Framework) AssertSession

func (fw *Framework) AssertSession(t *testing.T)

func (*Framework) MustNewClient

func (fw *Framework) MustNewClient(username string) *Client

func (*Framework) NewClient

func (fw *Framework) NewClient(username string) (*Client, error)

func (*Framework) RecordEvents

func (fw *Framework) RecordEvents(events ...string)

func (*Framework) RegisterUser

func (fw *Framework) RegisterUser(username string) (string, error)

func (*Framework) SetupDB

func (fw *Framework) SetupDB() error

func (*Framework) Step

func (fw *Framework) Step(name string, f func(), waitNResponses uint32)

Step 1. Adds a new step to the session 2. Runs the function 3. Locks until the number of responses to be recorded is reached

It is important that all incoming events are counted and not just recorded ones.

func (*Framework) TestMain

func (fw *Framework) TestMain(m *testing.M)

func (*Framework) UseShortener

func (fw *Framework) UseShortener(event string, sh session.Shortener)

type H

type H = map[string]any

type HandlerFunc

type HandlerFunc func(c *Client, arg interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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