Help us shape the future of Go! Take the 2026 Go Developer Survey

test

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 3 Imported by: 0

README

FSM

Test

Test is an integration test target for fsm.

Getting Started

From a high level, this library provides you the ability to generate a special fsm.Traverser that provides some additional functionality that will help you with testing a bot.

Usage for Test is best described through concrete example, so check out the fsm/getting-started test file.

License

MIT

Documentation

Index

Constants

View Source
const Platform = "fsm.test"

Variables

This section is empty.

Functions

This section is empty.

Types

type TestingTraverser

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

TestingTraverser is a fsm.Traverser, with an additional three methods: Send(), GetReceived(), and GetAllReceived()

func New

func New(stateMachine fsm.StateMachine, store fsm.Store) *TestingTraverser

New creates and returns a new *TestingTraverser, which can be used to build automated tests for State Machines

func (*TestingTraverser) CurrentState

func (t *TestingTraverser) CurrentState() string

CurrentState returns the current active state the Traverser is in. Be sure to call this only after you have called at least one `Send()` to this Traverser.

func (*TestingTraverser) Delete

func (t *TestingTraverser) Delete(key string)

Delete deletes a variable set to this traverser. Be sure to call this only after you have called at least one `Send()` to this Traverser.

func (*TestingTraverser) Fetch

func (t *TestingTraverser) Fetch(key string) interface{}

Fetch returns a variable set to this traverser. Be sure to call this only after you have called at least one `Send()` to this Traverser.

func (*TestingTraverser) GetAllReceived

func (t *TestingTraverser) GetAllReceived() []interface{}

GetAllReceived returns an array of all of the messages sent to this traverser. Think of this as a queue, and GetAllReceived() is simply flush().

func (*TestingTraverser) GetReceived

func (t *TestingTraverser) GetReceived() interface{}

GetReceived returns the first message that was sent to the traverser that hasn't been received yet. Think of this as a queue and GetReceived() is simply dequeue().

func (*TestingTraverser) Platform

func (t *TestingTraverser) Platform() string

Platform returns the Traversers Platform

func (*TestingTraverser) Send

func (t *TestingTraverser) Send(input string)

Send emulates a user sending a message to a chat-bot.

func (*TestingTraverser) SetCurrentState

func (t *TestingTraverser) SetCurrentState(state string)

SetCurrentState sets the current state. This can be useful for jumping around specific parts of your bot flow. Be sure to call this only after you have called at least one `Send()` to this Traverser.

func (*TestingTraverser) SetPlatform

func (t *TestingTraverser) SetPlatform(platform string)

SetPlatform sets the Traversers Platform

func (*TestingTraverser) SetUUID

func (t *TestingTraverser) SetUUID(uuid string)

SetUUID sets a new UUID to the traverser. It's not advised to set this yourself. Be sure to call this only after you have called at least one `Send()` to this Traverser.

func (*TestingTraverser) UUID

func (t *TestingTraverser) UUID() string

UUID returns the Traversers UUID

func (*TestingTraverser) Upsert

func (t *TestingTraverser) Upsert(key string, value interface{})

Upsert updates (or creates) a variable for this traverser. Be sure to call this only after you have called at least one `Send()` to this Traverser.

Jump to

Keyboard shortcuts

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