owmock

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeys

func GenerateKeys() (pub string, priv string)

GenerateKeys generates a new keypair of hex-encoded keys They shouldn't change between runs, but there's a generator just in case

PubK: 2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee

PrivK: 31323334353637383930313233343536373839303132333435363738393031322f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer makes requests

type InteractionResponse

type InteractionResponse struct {
	Type corde.InteractionType     `json:"type"`
	Data corde.InteractionRespData `json:"data,omitempty"`
}

type interaction callback type the type of response data? interaction callback data an optional response message

type Requester

type Requester struct {
	Client     Doer
	URL        string
	PrivateKey ed25519.PrivateKey
}

Requester makes requests to the mock endpoint

func New

func New(endpointURL string) *Requester

New returns a new mock requester

func NewWithClient

func NewWithClient(endpointURL string, c Doer) *Requester

NewWithClient returns a new mock requester with a default client

func (*Requester) Post

func (r *Requester) Post(body string) (json.RawMessage, error)

PostJSON makes a POST request to the endpoint with the given body

func (*Requester) PostExpect

func (r *Requester) PostExpect(t *testing.T, body string, expectV any) error

PostExpect posts a payload and expects a response with the given body

func (*Requester) PostJSON

func (r *Requester) PostJSON(body any) (json.RawMessage, error)

PostJSON makes a POST request to the endpoint with the given body marshalled

type ResponseWriterMock added in v0.6.0

type ResponseWriterMock struct {
	RespondHook      func(corde.InteractionResponder)
	UpdateHook       func(corde.InteractionResponder)
	AutocompleteHook func(corde.InteractionResponder)
	ModalHook        func(corde.Modal)

	T *testing.T
}

ResponseWriterMock mocks corde's ResponseWriter interface

func NewRWMock added in v0.6.0

func NewRWMock(t *testing.T) ResponseWriterMock

NewRWMock returns a new ResponseWriterMock with the given testing.T

func (ResponseWriterMock) Ack added in v0.8.0

func (r ResponseWriterMock) Ack()

Pong implements ResponseWriter interface

func (ResponseWriterMock) Autocomplete added in v0.6.0

func (r ResponseWriterMock) Autocomplete(i corde.InteractionResponder)

Autocomplete implements ResponseWriter interface

func (ResponseWriterMock) DeferedRespond added in v0.6.0

func (r ResponseWriterMock) DeferedRespond()

DeferedRespond implements ResponseWriter interface

func (ResponseWriterMock) DeferedUpdate added in v0.6.0

func (r ResponseWriterMock) DeferedUpdate()

DeferedUpdate implements ResponseWriter interface

func (ResponseWriterMock) Modal added in v0.8.0

func (r ResponseWriterMock) Modal(m corde.Modal)

Modal implements ResponseWriter interface

func (ResponseWriterMock) Respond added in v0.6.0

Response implements ResponseWriter interface

func (ResponseWriterMock) Update added in v0.6.0

Update implements ResponseWriter interface

Jump to

Keyboard shortcuts

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