test

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 16 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Quiet = false

Functions

func AssertEventIDsEqual

func AssertEventIDsEqual(t *testing.T, gotEventIDs []string, wants []*gomatrixserverlib.HeaderedEvent)

func AssertEventsEqual

func AssertEventsEqual(t *testing.T, gots, wants []*gomatrixserverlib.HeaderedEvent)

func PrepareDBConnectionString

func PrepareDBConnectionString(t *testing.T, dbType DBType) (connStr string, close func())

Prepare a sqlite or postgres connection string for testing. Returns the connection string to use and a close function which must be called when the test finishes. Calling this function twice will return the same database, which will have data from previous tests unless close() is called. TODO: namespace for concurrent package tests

func Reversed

Reverse a list of events

func RoomPreset

func RoomPreset(p Preset) roomModifier

func RoomVersion

func RoomVersion(ver gomatrixserverlib.RoomVersion) roomModifier

func WithAllDatabases

func WithAllDatabases(t *testing.T, testFn func(t *testing.T, db DBType))

Creates subtests with each known DBType

func WithStateKey

func WithStateKey(skey string) eventModifier

func WithTimestamp

func WithTimestamp(ts time.Time) eventModifier

func WithUnsigned

func WithUnsigned(unsigned interface{}) eventModifier

Types

type DBType

type DBType int
var DBTypePostgres DBType = 2
var DBTypeSQLite DBType = 1

type Preset

type Preset int
var (
	PresetNone               Preset = 0
	PresetPrivateChat        Preset = 1
	PresetPublicChat         Preset = 2
	PresetTrustedPrivateChat Preset = 3
)

type Room

type Room struct {
	ID      string
	Version gomatrixserverlib.RoomVersion
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(t *testing.T, creator *User, modifiers ...roomModifier) *Room

Create a new test room. Automatically creates the initial create events.

func (*Room) CreateAndInsert

func (r *Room) CreateAndInsert(t *testing.T, creator *User, eventType string, content interface{}, mods ...eventModifier) *gomatrixserverlib.HeaderedEvent

func (*Room) CreateEvent

func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, content interface{}, mods ...eventModifier) *gomatrixserverlib.HeaderedEvent

Create an event in this room but do not insert it. Does not modify the room in any way (depth, fwd extremities, etc) so is thread-safe.

func (*Room) Events

func (r *Room) Events() []*gomatrixserverlib.HeaderedEvent

func (*Room) InsertEvent

func (r *Room) InsertEvent(t *testing.T, he *gomatrixserverlib.HeaderedEvent)

Add a new event to this room DAG. Not thread-safe.

type User

type User struct {
	ID string
}

func NewUser

func NewUser() *User

Jump to

Keyboard shortcuts

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