btest

package
v0.0.0-...-0e61348 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 55 Imported by: 0

Documentation

Overview

Package btest implements a script test system for the bot package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunScript

func RunScript(t testing.TB, filename string, freshDB func(t testing.TB) *sql.DB)

RunScript runs the a single script test.

Types

type Sender

type Sender interface {
	SendMessage(ctx context.Context, origin, target, message string) error
}

Sender sends a single message back via an origin (bot name) to the specified target (channel).

type SenderMock

type SenderMock struct {
	// SendMessageFunc mocks the SendMessage method.
	SendMessageFunc func(ctx context.Context, origin string, target string, message string) error
	// contains filtered or unexported fields
}

SenderMock is a mock implementation of Sender.

func TestSomethingThatUsesSender(t *testing.T) {

	// make and configure a mocked Sender
	mockedSender := &SenderMock{
		SendMessageFunc: func(ctx context.Context, origin string, target string, message string) error {
			panic("mock out the SendMessage method")
		},
	}

	// use mockedSender in code that requires Sender
	// and then make assertions.

}

func (*SenderMock) SendMessage

func (mock *SenderMock) SendMessage(ctx context.Context, origin string, target string, message string) error

SendMessage calls SendMessageFunc.

func (*SenderMock) SendMessageCalls

func (mock *SenderMock) SendMessageCalls() []struct {
	Ctx     context.Context
	Origin  string
	Target  string
	Message string
}

SendMessageCalls gets all the calls that were made to SendMessage. Check the length with:

len(mockedSender.SendMessageCalls())

Jump to

Keyboard shortcuts

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