test

package
v0.0.0-...-a2de6b1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UpdateSnapshots bool

UpdateSnapshots indicates whether tests should update snapshots

Functions

func AssertEqualJSON

func AssertEqualJSON(t *testing.T, expected json.RawMessage, actual json.RawMessage, msgAndArgs ...interface{}) bool

AssertEqualJSON checks two JSON strings for equality

func AssertSnapshot

func AssertSnapshot(t *testing.T, name, expected string)

AssertSnapshot checks that the file contains the expected text. However it creates the file if -update was set or file doesn't exist.

func AssertXEqual

func AssertXEqual(t *testing.T, expected types.XValue, actual types.XValue, msgAndArgs ...interface{}) bool

AssertXEqual is equivalent to assert.Equal for two XValue instances

func CreateSessionAssets

func CreateSessionAssets(assetsJSON json.RawMessage, testServerURL string) (flows.SessionAssets, error)

CreateSessionAssets creates assets from given JSON

func CreateTestSession

func CreateTestSession(testServerURL string, redact envs.RedactionPolicy) (flows.Session, []flows.Event, error)

CreateTestSession creates a standard example session for testing

func CreateTestVoiceSession

func CreateTestVoiceSession(testServerURL string) (flows.Session, []flows.Event, error)

CreateTestVoiceSession creates a standard example session for testing voice flows and actions

func JSONDelete

func JSONDelete(data json.RawMessage, path []string) json.RawMessage

JSONDelete deletes a node in JSON

func JSONReplace

func JSONReplace(data json.RawMessage, path []string, value json.RawMessage) json.RawMessage

JSONReplace replaces a node in JSON

func LoadFlowFromAssets

func LoadFlowFromAssets(env envs.Environment, path string, uuid assets.FlowUUID) (flows.Flow, error)

func LoadSessionAssets

func LoadSessionAssets(env envs.Environment, path string) (flows.SessionAssets, error)

LoadSessionAssets loads a session assets instance from a static JSON file

func NewChannel

func NewChannel(name string, address string, schemes []string, roles []assets.ChannelRole, parent *assets.ChannelReference) *flows.Channel

func NewClassifier

func NewClassifier(name, type_ string, intents []string) *flows.Classifier

func NewEngine

func NewEngine() flows.Engine

NewEngine creates an engine instance for testing

func NewTelChannel

func NewTelChannel(name string, address string, roles []assets.ChannelRole, parent *assets.ChannelReference, country envs.Country, matchPrefixes []string, allowInternational bool) *flows.Channel

func NewTestHTTPServer

func NewTestHTTPServer(port int) *httptest.Server

NewTestHTTPServer sets up a mock server for webhook actions

func NewTicketService

func NewTicketService(ticketer *flows.Ticketer) flows.TicketService

NewTicketService creates a new ticket service for testing

func NormalizeJSON

func NormalizeJSON(data json.RawMessage) ([]byte, error)

NormalizeJSON re-formats the given JSON

func ResumeSession

func ResumeSession(session flows.Session, assetsJSON json.RawMessage, msgText string) (flows.Session, flows.Sprint, error)

ResumeSession resumes the given session with potentially different assets

Types

type EventLog

type EventLog struct {
	Events []flows.Event
}

EventLog is a utility for testing things which take an event logger function

func NewEventLog

func NewEventLog() *EventLog

NewEventLog creates a new event log

func (*EventLog) Log

func (l *EventLog) Log(e flows.Event)

type SessionBuilder

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

func NewSessionBuilder

func NewSessionBuilder() *SessionBuilder

func (*SessionBuilder) Build

func (b *SessionBuilder) Build() (flows.Session, flows.Sprint, error)

func (*SessionBuilder) MustBuild

func (b *SessionBuilder) MustBuild() (flows.Session, flows.Sprint)

func (*SessionBuilder) WithAssets

func (b *SessionBuilder) WithAssets(assetsJSON []byte) *SessionBuilder

func (*SessionBuilder) WithAssetsPath

func (b *SessionBuilder) WithAssetsPath(path string) *SessionBuilder

func (*SessionBuilder) WithContact

func (b *SessionBuilder) WithContact(uuid flows.ContactUUID, id flows.ContactID, name string, lang envs.Language, urn urns.URN) *SessionBuilder

func (*SessionBuilder) WithEnvironment

func (b *SessionBuilder) WithEnvironment(env envs.Environment) *SessionBuilder

func (*SessionBuilder) WithFlow

func (b *SessionBuilder) WithFlow(flowUUID assets.FlowUUID) *SessionBuilder

func (*SessionBuilder) WithTriggerMsg

func (b *SessionBuilder) WithTriggerMsg(text string) *SessionBuilder

Jump to

Keyboard shortcuts

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