mocks

package
v2.3.19 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContainsSlackBlocks

func AssertContainsSlackBlocks(t *testing.T, slackClient *SlackClient, message msg.Ref, block slack.Block)

AssertContainsSlackBlocks is a small test helper to check for certain slack.Block

func AssertError

func AssertError(slackClient *SlackClient, ref msg.Ref, errorIn any)

AssertError is a test helper which check for calls to "ReplyError"

func AssertQueuedMessage

func AssertQueuedMessage(t *testing.T, expected msg.Message)

AssertQueuedMessage checks if a given internal message was queued

func AssertReaction

func AssertReaction(slackClient *SlackClient, reaction string, ref msg.Ref)

AssertReaction is a test helper to expect a given slack reaction to be added

func AssertRemoveReaction

func AssertRemoveReaction(slackClient *SlackClient, reaction string, ref msg.Ref)

AssertRemoveReaction is a test helper to expect a given slack reaction to be removed

func AssertSlackBlocks

func AssertSlackBlocks(t *testing.T, slackClient *SlackClient, message msg.Ref, expectedJSON string)

AssertSlackBlocks test helper to assert a given JSON representation of "Blocks"

func AssertSlackEphemeralMessage added in v2.3.15

func AssertSlackEphemeralMessage(slackClient *SlackClient, ref msg.Ref, text string, option ...any)

AssertSlackEphemeralMessage is a test helper to check for a given ephemeral slack message

func AssertSlackJSON

func AssertSlackJSON(t *testing.T, slackClient *SlackClient, message msg.Ref, expected string)

AssertSlackJSON is a test helper to assert full slack attachments

func AssertSlackMessage

func AssertSlackMessage(slackClient *SlackClient, ref msg.Ref, text string, option ...any)

AssertSlackMessage is a test helper to check for a given slack message

func AssertSlackMessageRegexp added in v2.2.4

func AssertSlackMessageRegexp(slackClient *SlackClient, ref msg.Ref, pattern string)

AssertSlackMessageRegexp is a test helper to check for a given slack message based on a regular expression

func GetAttachmentJSON added in v2.3.18

func GetAttachmentJSON(opt slack.MsgOption) string

GetAttachmentJSON extracts the attachment JSON from a MsgOption by posting to a local test server. Use this as a replacement for slack.UnsafeApplyMsgOptions which no longer populates attachment values.

func LockInternalMessages

func LockInternalMessages() *sync.Mutex

LockInternalMessages uses mutex to block other tests dealing with the central message queue

func NewPseudoRandom added in v2.2.10

func NewPseudoRandom() *rand.Rand

NewPseudoRandom returns a deterministic random source for testing purposes. In production, random seed is used

func WaitForQueuedMessages added in v2.2.6

func WaitForQueuedMessages(t *testing.T, count int) func() []msg.Message

WaitForQueuedMessages waits until all "count" messages are queued and returns them in the returned function. We get a failed test when there are more messages than expected or not enough messages after 1 second of timeout.

func WaitTillHavingInternalMessage

func WaitTillHavingInternalMessage() msg.Message

WaitTillHavingInternalMessage blocks until there is a internal message queued. If there is no message after 2s -> exit!

Types

type Client

type Client struct {
	mock.Mock
}

Client is an autogenerated mock type for the Client type

func NewClient added in v2.2.10

func NewClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *Client

NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*Client) BuildJob

func (_m *Client) BuildJob(ctx context.Context, name string, params map[string]string) (int64, error)

BuildJob provides a mock function with given fields: ctx, name, params

func (*Client) GetAllNodes

func (_m *Client) GetAllNodes(ctx context.Context) ([]*gojenkins.Node, error)

GetAllNodes provides a mock function with given fields: ctx

func (*Client) GetJob

func (_m *Client) GetJob(ctx context.Context, id string) (*gojenkins.Job, error)

GetJob provides a mock function with given fields: ctx, id

type SlackClient

type SlackClient struct {
	mock.Mock
}

SlackClient is an autogenerated mock type for the SlackClient type

func NewSlackClient added in v2.2.10

func NewSlackClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *SlackClient

NewSlackClient creates a new instance of SlackClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*SlackClient) AddReaction

func (_m *SlackClient) AddReaction(reaction util.Reaction, ref msg.Ref)

AddReaction provides a mock function with given fields: reaction, ref

func (*SlackClient) GetConversationHistory

GetConversationHistory provides a mock function with given fields: _a0

func (*SlackClient) GetFile added in v2.3.18

func (_m *SlackClient) GetFile(downloadURL string, writer io.Writer) error

GetFile provides a mock function with given fields: downloadURL, writer

func (*SlackClient) GetReactions

func (_m *SlackClient) GetReactions(item slack.ItemRef, params slack.GetReactionsParameters) (slack.ReactedItem, error)

GetReactions provides a mock function with given fields: item, params

func (*SlackClient) GetThreadMessages added in v2.2.10

func (_m *SlackClient) GetThreadMessages(ref msg.Ref) ([]slack.Message, error)

GetThreadMessages provides a mock function with given fields: ref

func (*SlackClient) GetUserPresence added in v2.2.10

func (_m *SlackClient) GetUserPresence(user string) (*slack.UserPresence, error)

GetUserPresence provides a mock function with given fields: user

func (*SlackClient) PinMessage added in v2.3.9

func (_m *SlackClient) PinMessage(channel string, timestamp string) error

PinMessage provides a mock function with given fields: channel, timestamp

func (*SlackClient) RemoveReaction

func (_m *SlackClient) RemoveReaction(reaction util.Reaction, ref msg.Ref)

RemoveReaction provides a mock function with given fields: reaction, ref

func (*SlackClient) ReplyError

func (_m *SlackClient) ReplyError(ref msg.Ref, err error)

ReplyError provides a mock function with given fields: ref, err

func (*SlackClient) SendBlockMessage

func (_m *SlackClient) SendBlockMessage(ref msg.Ref, blocks []slack.Block, options ...slack.MsgOption) string

SendBlockMessage provides a mock function with given fields: ref, blocks, options

func (*SlackClient) SendBlockMessageToUser added in v2.2.10

func (_m *SlackClient) SendBlockMessageToUser(user string, blocks []slack.Block, options ...slack.MsgOption) string

SendBlockMessageToUser provides a mock function with given fields: user, blocks, options

func (*SlackClient) SendEphemeralMessage added in v2.2.4

func (_m *SlackClient) SendEphemeralMessage(ref msg.Ref, text string, options ...slack.MsgOption)

SendEphemeralMessage provides a mock function with given fields: ref, text, options

func (*SlackClient) SendMessage

func (_m *SlackClient) SendMessage(ref msg.Ref, text string, options ...slack.MsgOption) string

SendMessage provides a mock function with given fields: ref, text, options

func (*SlackClient) SendToUser

func (_m *SlackClient) SendToUser(user string, text string)

SendToUser provides a mock function with given fields: user, text

func (*SlackClient) UploadFile added in v2.2.10

func (_m *SlackClient) UploadFile(params slack.UploadFileParameters) (*slack.FileSummary, error)

UploadFile provides a mock function with given fields: params

Jump to

Keyboard shortcuts

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