assertplugin

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asserter

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

Asserter represents a plugin driver/asserter and holds the bot identifier that tests are using when sending test messages for processing

func New

func New(botUserID string) (a *Asserter)

New creates a new asserter with the given botUserId (only include the id without the '@' prefix). The botUserId is used in order to detect commands formed with <@botUserId>

func (*Asserter) AnswersAndReacts

func (a *Asserter) AnswersAndReacts(t *testing.T, p *slackscot.Plugin, m *slack.Msg, validate ResultValidator) (valid bool)

AnswersAndReacts drives a plugin and collects Answers as well as emoji reactions. Once all of those have been collected, it passes handling to a validator to assert the expected answers and emoji reactions. It follows the style of github.com/stretchr/testify/assert as far as returning true/false to indicate success for further nested testing.

Note that all commands and hearActions are evaluated but this is a simplified version of how slackscot actually drives plugins and aims to provide the minimal processing required to allow a plugin to test functionality given an incoming message. Users should take special care to use include <@botUserID> with the same botUserID with which the plugin driver has been instantiated in the message text inputs to test commands (or include a channel name that starts with D for direct channel testing)

type ResultValidator

type ResultValidator func(t *testing.T, answers []*slackscot.Answer, emojis []string) bool

ResultValidator is a function to do further validation of the answers and emoji reactions resulting from a plugin processing of all of its commands and hear actions. The return value is meant to be true if validation is successful and false otherwise (following the testify convention)

Jump to

Keyboard shortcuts

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