queuetest

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package queuetest provides a mock implementation of gas.JobQueueProvider for use in tests. The mock records all calls and allows configuring per-method behavior via function fields.

mock := &queuetest.MockQueue{}
mock.EnqueueFn = func(ctx context.Context, queue string, payload []byte, opts ...gas.EnqueueOption) error {
    return nil
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	Args   []any
}

Call records a single method invocation on the mock.

type MockQueue

type MockQueue struct {
	EnqueueFn func(ctx context.Context, queue string, payload []byte, opts ...gas.EnqueueOption) error
	DequeueFn func(ctx context.Context, queue string, maxMessages int, wait time.Duration) ([]gas.Job, error)
	AckFn     func(ctx context.Context, queue string, job gas.Job) error
	NackFn    func(ctx context.Context, queue string, job gas.Job) error
	Calls     []Call
	// contains filtered or unexported fields
}

MockQueue is a configurable mock of gas.JobQueueProvider. Each method delegates to its corresponding Fn field if set, otherwise returns the zero value. All calls are recorded in the Calls slice for assertions.

func (*MockQueue) Ack

func (m *MockQueue) Ack(ctx context.Context, queue string, job gas.Job) error

Ack records the call and delegates to AckFn if set.

func (*MockQueue) CallCount

func (m *MockQueue) CallCount(method string) int

CallCount returns the number of times the given method was called.

func (*MockQueue) Dequeue

func (m *MockQueue) Dequeue(ctx context.Context, queue string, maxMessages int, wait time.Duration) ([]gas.Job, error)

Dequeue records the call and delegates to DequeueFn if set.

func (*MockQueue) Enqueue

func (m *MockQueue) Enqueue(ctx context.Context, queue string, payload []byte, opts ...gas.EnqueueOption) error

Enqueue records the call and delegates to EnqueueFn if set.

func (*MockQueue) Nack

func (m *MockQueue) Nack(ctx context.Context, queue string, job gas.Job) error

Nack records the call and delegates to NackFn if set.

func (*MockQueue) Reset

func (m *MockQueue) Reset()

Reset clears all recorded calls.

Jump to

Keyboard shortcuts

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