assertanswer

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package assertanswer provides testing functions to validate a plugin's answer

This package is most useful when used in combination with github.com/alexandre-normand/slackscot/test/assertplugin but can be used alone to test individual slackscot Actions.

Example of a typical usage also using assertplugin:

   func TestPlugin(t *testing.T) {
       assertplugin := assertplugin.New(t, "bot")
       yourPlugin := newPlugin()

       assertplugin.AnswersAndReacts(yourPlugin, &slack.Msg{Text: "are you up?"}, func(t *testing.T, answers []*slackscot.Answer, emojis []string) bool {
	          return assert.Len(t, answers, 1) && assertanswer.HasText(t, answers[0], "I'm 😴, you?")
       }))
   }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasOptions

func HasOptions(t *testing.T, answer *slackscot.Answer, options ...ResolvedAnswerOption) bool

HasOptions asserts that the answer's options contains the expected configuration key/values

func HasText

func HasText(t *testing.T, answer *slackscot.Answer, text string) bool

HasText asserts that the answer's text is the expected text

func HasTextContaining

func HasTextContaining(t *testing.T, answer *slackscot.Answer, subString string) bool

HasTextContaining asserts that the answer's text contains the expected subString

Types

type ResolvedAnswerOption

type ResolvedAnswerOption struct {
	Key   string
	Value string
}

ResolvedAnswerOption holds a pair of Key/Value representing the physical AnswerOption

Jump to

Keyboard shortcuts

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