testpayload

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCounter

func GenerateCounter() int

func GenerateNowDateTime

func GenerateNowDateTime() string

func GenerateRandomCBOR

func GenerateRandomCBOR() ([]byte, error)

GenerateRandomCBOR creates a CBOR with predictable structure and random values

func GenerateRandomDateTime

func GenerateRandomDateTime() string

func GenerateRandomJSON

func GenerateRandomJSON() ([]byte, error)

GenerateRandomJSON creates a JSON with predictable structure and random values

func GenerateSentence

func GenerateSentence() string

GenerateSentence generates a random sentence for tests

func GenerateSentimentPhrase

func GenerateSentimentPhrase() string

func Interpolate

func Interpolate(str string) ([]byte, error)

func InterpolateWithDelimiters

func InterpolateWithDelimiters(str string, openDelim string, closeDelim string) ([]byte, error)

InterpolateWithDelimiters performs template variable interpolation with custom delimiters Supports placeholders: json, cbor, sentiment, sentence, datetime, nowtime, counter, file:/path

Types

type Payload

type Payload struct {
	ID     string  `faker:"uuid_hyphenated" json:"id"`
	Name   string  `faker:"name" json:"name"`
	Value  float64 `faker:"lat" json:"value"` // use lat as random float
	Active bool    `json:"active"`
	Time   int64   `faker:"unix_time" json:"time"`
}

Payload represents the predictable payload structure faker annotates fields for automatic generation https://github.com/go-faker/faker#supported-tags

type TestPayloadType

type TestPayloadType string
const (
	TestPayloadJSON      TestPayloadType = "json"
	TestPayloadCBOR      TestPayloadType = "cbor"
	TestPayloadSentiment TestPayloadType = "sentiment"
	TestPayloadSentence  TestPayloadType = "sentence"
	TestPayloadDateTime  TestPayloadType = "datetime" // to generate a timestamp
	TestPayloadNowTime   TestPayloadType = "nowtime"  // to generate the current timestamp
	TestPayloadCounter   TestPayloadType = "counter"  // to generate an incrementing counter (not implemented yet
)

func (TestPayloadType) Generate

func (t TestPayloadType) Generate() ([]byte, error)

func (TestPayloadType) GetContentType

func (t TestPayloadType) GetContentType() string

func (TestPayloadType) IsValid

func (t TestPayloadType) IsValid() bool

Jump to

Keyboard shortcuts

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