generator

package
v0.0.0-...-258bf39 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertIntField

func AssertIntField(t *testing.T, data Data, field string, expected int)

func AssertStringField

func AssertStringField(t *testing.T, data Data, field string, expected string)

func InitDumb

func InitDumb()

InitDumb initializes generator in predictable mode for tests

Types

type Context

type Context struct {
}

Context holds the context information, like current depth or settings for the process

type Data

type Data map[string]interface{}

Data is map to which generator puts data

type Generator

type Generator func(Data, *Context)

Generator is function that fills provided Data map with generated values

func Compose

func Compose(f Generator, g Generator) Generator

Compose is a helper function that composes 2 generators. If one is nil, returns other without changes. if both are not nil - creates a wrapper function that calls first generator and then calls second one

func GenerateInt

func GenerateInt(field string) Generator

GenerateInt generates uint

func GenerateString

func GenerateString(field string) Generator

GenerateString generates a random word

type ObjGenerator

type ObjGenerator func() Data

ObjGenerator is a generator for object

func NewObjGenerator

func NewObjGenerator(g Generator) ObjGenerator

NewObjGenerator returns an ObjGenerator function. This function creates instance of Data and Context Then calls generator provided as argument and returns Data filled with generated values.

Jump to

Keyboard shortcuts

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