Documentation
¶
Index ¶
- Variables
- func AssertEqualJSON(t *testing.T, expected []byte, actual []byte, msgAndArgs ...any) bool
- func AssertSnapshot(t *testing.T, name, expected string)
- func AssertXEqual(t *testing.T, expected types.XValue, actual types.XValue, msgAndArgs ...any) bool
- func CreateSessionAssets(assetsJSON []byte, testServerURL string) (flows.SessionAssets, error)
- func CreateTestSession(testServerURL string, redact envs.RedactionPolicy) (flows.Session, []events.Event, error)
- func CreateTestVoiceSession(testServerURL string) (flows.Session, []events.Event, error)
- func JSONDelete(data []byte, path []string) []byte
- func JSONReplace(data []byte, path []string, value []byte) []byte
- func LoadFlowFromAssets(env envs.Environment, path string, uuid assets.FlowUUID) (flows.Flow, error)
- func LoadSessionAssets(env envs.Environment, path string) (flows.SessionAssets, error)
- func MockUniverse() func()
- func MockWebhooksHandler(w http.ResponseWriter, r *http.Request)
- func MockedHTTP(mocks map[string][]*httpx.MockResponse) (*http.Client, *httpx.MocksTransport)
- func NewChannel(name string, address string, schemes []string, roles []assets.ChannelRole, ...) *core.Channel
- func NewEngine() flows.Engine
- func NewHTTPServer(port int, handler http.HandlerFunc) *httptest.Server
- func NewMockedEngine(mocks map[string][]*httpx.MockResponse) flows.Engine
- func NewTelChannel(name string, address string, roles []assets.ChannelRole, ...) *core.Channel
- func NormalizeJSON(data []byte) ([]byte, error)
- func ResumeSession(session flows.Session, sa flows.SessionAssets, msgText string) (flows.Session, flows.Sprint, error)
- func RootError(err error) error
- type EventLog
- type SessionBuilder
- func (b *SessionBuilder) Build() (flows.SessionAssets, flows.Session, flows.Sprint, error)
- func (b *SessionBuilder) MustBuild() (flows.SessionAssets, flows.Session, flows.Sprint)
- func (b *SessionBuilder) WithAssets(sa flows.SessionAssets) *SessionBuilder
- func (b *SessionBuilder) WithAssetsJSON(assetsJSON []byte) *SessionBuilder
- func (b *SessionBuilder) WithAssetsPath(path string) *SessionBuilder
- func (b *SessionBuilder) WithContact(uuid core.ContactUUID, id flows.ContactID, name string, lang i18n.Language, ...) *SessionBuilder
- func (b *SessionBuilder) WithEnvironment(env envs.Environment) *SessionBuilder
- func (b *SessionBuilder) WithFlow(flowUUID assets.FlowUUID) *SessionBuilder
- func (b *SessionBuilder) WithMocks(mocks map[string][]*httpx.MockResponse) *SessionBuilder
- func (b *SessionBuilder) WithTriggerMsg(text string) *SessionBuilder
Constants ¶
This section is empty.
Variables ¶
var MockStartTime = time.Date(2025, 5, 4, 12, 30, 45, 123456789, time.UTC)
MockStartTime is the start time used by MockUniverse
var UpdateSnapshots bool
UpdateSnapshots indicates whether tests should update snapshots
Functions ¶
func AssertEqualJSON ¶ added in v0.23.0
AssertEqualJSON checks two JSON strings for equality
func AssertSnapshot ¶ added in v0.87.0
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.33.8
AssertXEqual is equivalent to assert.Equal for two XValue instances
func CreateSessionAssets ¶ added in v0.38.0
func CreateSessionAssets(assetsJSON []byte, testServerURL string) (flows.SessionAssets, error)
CreateSessionAssets creates assets from given JSON
func CreateTestSession ¶
func CreateTestSession(testServerURL string, redact envs.RedactionPolicy) (flows.Session, []events.Event, error)
CreateTestSession creates a standard example session for testing
func CreateTestVoiceSession ¶ added in v0.24.0
CreateTestVoiceSession creates a standard example session for testing voice flows and actions
func JSONDelete ¶ added in v0.50.0
JSONDelete deletes a node in JSON
func JSONReplace ¶ added in v0.39.0
JSONReplace replaces a node in JSON
func LoadFlowFromAssets ¶ added in v0.29.0
func LoadSessionAssets ¶ added in v0.25.0
func LoadSessionAssets(env envs.Environment, path string) (flows.SessionAssets, error)
LoadSessionAssets loads a session assets instance from a static JSON file
func MockUniverse ¶ added in v0.243.3
func MockUniverse() func()
MockUniverse mocks time and random generators for testing
func MockWebhooksHandler ¶ added in v0.256.10
func MockWebhooksHandler(w http.ResponseWriter, r *http.Request)
MockWebhooksHandler is our standard handler for testing webhooks
func MockedHTTP ¶ added in v0.277.0
func MockedHTTP(mocks map[string][]*httpx.MockResponse) (*http.Client, *httpx.MocksTransport)
MockedHTTP creates an HTTP client whose requests are answered from the given mocks rather than being sent. It also returns the mocking transport so tests can assert against it, e.g. that all mocks were used (mocks.HasUnused()).
func NewChannel ¶ added in v0.15.0
func NewChannel(name string, address string, schemes []string, roles []assets.ChannelRole, features []assets.ChannelFeature) *core.Channel
func NewHTTPServer ¶ added in v0.256.10
func NewHTTPServer(port int, handler http.HandlerFunc) *httptest.Server
NewHTTPServer sets up a mock server
func NewMockedEngine ¶ added in v0.277.0
func NewMockedEngine(mocks map[string][]*httpx.MockResponse) flows.Engine
NewMockedEngine creates an engine instance for testing whose webhook calls are answered from the given mocks
func NewTelChannel ¶ added in v0.15.0
func NormalizeJSON ¶ added in v0.23.0
NormalizeJSON re-formats the given JSON
Types ¶
type EventLog ¶ added in v0.51.0
EventLog is a utility for testing things which take an event logger function
func NewEventLog ¶ added in v0.51.0
func NewEventLog() *EventLog
NewEventLog creates a new event log
type SessionBuilder ¶ added in v0.143.2
type SessionBuilder struct {
// contains filtered or unexported fields
}
func NewSessionBuilder ¶ added in v0.143.2
func NewSessionBuilder() *SessionBuilder
func (*SessionBuilder) Build ¶ added in v0.143.2
func (b *SessionBuilder) Build() (flows.SessionAssets, flows.Session, flows.Sprint, error)
func (*SessionBuilder) MustBuild ¶ added in v0.143.2
func (b *SessionBuilder) MustBuild() (flows.SessionAssets, flows.Session, flows.Sprint)
func (*SessionBuilder) WithAssets ¶ added in v0.143.2
func (b *SessionBuilder) WithAssets(sa flows.SessionAssets) *SessionBuilder
func (*SessionBuilder) WithAssetsJSON ¶ added in v0.165.2
func (b *SessionBuilder) WithAssetsJSON(assetsJSON []byte) *SessionBuilder
func (*SessionBuilder) WithAssetsPath ¶ added in v0.143.2
func (b *SessionBuilder) WithAssetsPath(path string) *SessionBuilder
func (*SessionBuilder) WithContact ¶ added in v0.143.2
func (b *SessionBuilder) WithContact(uuid core.ContactUUID, id flows.ContactID, name string, lang i18n.Language, urn urns.URN) *SessionBuilder
func (*SessionBuilder) WithEnvironment ¶ added in v0.143.2
func (b *SessionBuilder) WithEnvironment(env envs.Environment) *SessionBuilder
func (*SessionBuilder) WithFlow ¶ added in v0.143.2
func (b *SessionBuilder) WithFlow(flowUUID assets.FlowUUID) *SessionBuilder
func (*SessionBuilder) WithMocks ¶ added in v0.277.0
func (b *SessionBuilder) WithMocks(mocks map[string][]*httpx.MockResponse) *SessionBuilder
WithMocks builds the session's engine with an HTTP client that answers webhook calls from the given mocks
func (*SessionBuilder) WithTriggerMsg ¶ added in v0.143.2
func (b *SessionBuilder) WithTriggerMsg(text string) *SessionBuilder