test

package
v0.0.0-...-6e4db14 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package test provides a slack client implementation which uses the slack api.test endpoint so is suitable to testing.

See: https://api.slack.com/methods/api.test

Index

Examples

Constants

View Source
const (
	// Endpoint is the slack endpoint which can be used for testing calling code.
	Endpoint = "https://slack.com/api/api.test"
)

Variables

This section is empty.

Functions

func New

func New() *webhook.Client

New returns a new slack.Client that can be used for testing.

Example
c := New()
msg := struct {
	Param1 string
	Param2 int
}{Param1: "my value", Param2: 20}

resp := struct {
	slack.Response
	Args struct {
		Param1 string
		Param2 int
	}
}{}
if err := c.Send("", msg, resp); err != nil {
	// No error is expected here.
	fmt.Println("error:", err)
}
fmt.Println("response:", resp)
Output:

func NewError

func NewError(err string) *webhook.Client

NewError returns a new slack.Client that can be used for testing which errors with err.

Example
c := NewError("my error")
msg := struct {
	Param1 string
	Param2 int
}{Param1: "my value", Param2: 20}

resp := struct {
	slack.Response
	Args struct {
		Param1 string
		Param2 int
	}
}{}
if err := c.Send("", msg, resp); err != nil {
	// An error is expected here.
	fmt.Println("error:", err)
}
fmt.Println("response:", resp)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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