test

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 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 added in v0.23.0

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

AssertEqualJSON checks two JSON strings for equality

func AssertSnapshot added in v0.115.3

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 added in v0.115.3

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 added in v0.115.3

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 added in v0.115.3

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

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

func JSONDelete added in v0.115.3

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

JSONDelete deletes a node in JSON

func JSONReplace added in v0.115.3

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

JSONReplace replaces a node in JSON

func LoadFlowFromAssets added in v0.115.3

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

func LoadSessionAssets added in v0.115.3

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

LoadSessionAssets loads a session assets instance from a static JSON file

func NewChannel added in v0.15.0

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

func NewClassifier added in v0.115.3

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

func NewEngine added in v0.115.3

func NewEngine() flows.Engine

NewEngine creates an engine instance for testing

func NewTelChannel added in v0.15.0

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 added in v0.115.3

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

NewTicketService creates a new ticket service for testing

func NormalizeJSON added in v0.23.0

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

NormalizeJSON re-formats the given JSON

func ResumeSession added in v0.115.3

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 added in v0.115.3

type EventLog struct {
	Events []flows.Event
}

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

func NewEventLog added in v0.115.3

func NewEventLog() *EventLog

NewEventLog creates a new event log

func (*EventLog) Log added in v0.115.3

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

type SessionBuilder added in v0.115.3

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

func NewSessionBuilder added in v0.115.3

func NewSessionBuilder() *SessionBuilder

func (*SessionBuilder) Build added in v0.115.3

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

func (*SessionBuilder) MustBuild added in v0.115.3

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

func (*SessionBuilder) WithAssets added in v0.115.3

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

func (*SessionBuilder) WithAssetsPath added in v0.115.3

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

func (*SessionBuilder) WithContact added in v0.115.3

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

func (*SessionBuilder) WithEnvironment added in v0.115.3

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

func (*SessionBuilder) WithFlow added in v0.115.3

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

func (*SessionBuilder) WithTriggerMsg added in v0.115.3

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