factory

package
v0.0.0-...-7ed8402 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package factory contains helpers for instantiating tests.

Index

Examples

Constants

This section is empty.

Variables

View Source
var EmptyData = json.RawMessage([]byte("{}"))
View Source
var JobId types.PrefixUUID
View Source
var RD = &RandomData{
	Foo: []string{"bar", "pik_345"},
	Baz: uint8(17),
}
View Source
var SampleAtMostOnceJob = newmodels.CreateJobParams{
	Name:             "at-most-once",
	DeliveryStrategy: newmodels.DeliveryStrategyAtMostOnce,
	Attempts:         1,
	Concurrency:      5,
}
View Source
var SampleJob = newmodels.CreateJobParams{
	Name:             "echo",
	DeliveryStrategy: newmodels.DeliveryStrategyAtLeastOnce,
	Attempts:         7,
	Concurrency:      1,
}

Functions

func CreateArchivedJob

func CreateArchivedJob(t *testing.T, data json.RawMessage, status newmodels.ArchivedJobStatus) *newmodels.ArchivedJob

func CreateAtMostOnceJob

func CreateAtMostOnceJob(t *testing.T, data json.RawMessage) (*newmodels.Job, *newmodels.QueuedJob)

CreateAtMostOnceJob creates a queued job that can be run at most once.

func CreateQJ

func CreateQJ(t testing.TB) *newmodels.QueuedJob

CreateQJ creates a job with a random name, and a random UUID.

func CreateQueuedJob

func CreateQueuedJob(t testing.TB, data json.RawMessage) *newmodels.QueuedJob

CreateQueuedJob creates a job and a queued job with the given JSON data, and returns the created queued job.

Example
t := &testing.T{}
CreateQueuedJob(t, EmptyData)
Output:

func CreateQueuedJobOnly

func CreateQueuedJobOnly(t testing.TB, name string, data json.RawMessage)

func CreateUniqueQueuedJob

func CreateUniqueQueuedJob(t testing.TB, data json.RawMessage) (*newmodels.Job, *newmodels.QueuedJob)

Like the above but with unique ID's and job names

func Processor

func Processor(url string) *services.JobProcessor

Processor returns a simple JobProcessor, with a client pointing at the given URL, password set to "password" and various sleeps set to 0.

func RandomId

func RandomId(prefix string) types.PrefixUUID

RandomId returns a random UUID with the given prefix.

Example
RandomId("job_")
// Will return something like "job_5555b44e-13b9-475d-af06-979627e0e0d6"
Output:

Types

type RandomData

type RandomData struct {
	Foo []string `json:"foo"`
	Baz uint8    `json:"baz"`
}

Jump to

Keyboard shortcuts

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