Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package randomize has helpers for randomization of structs and fields
Index ¶
- func ByteSlice(s *Seed, ln int) []byte
 - func Date(s *Seed) time.Time
 - func EnumValue(s *Seed, enum string) (string, error)
 - func FormattedString(s *Seed, fieldType string) (string, bool)
 - func MediumInt(s *Seed, fieldType string) (int32, bool)
 - func StableDBName(input string) string
 - func Str(s *Seed, ln int) string
 - func Struct(s *Seed, str interface{}, colTypes map[string]string, canBeNull bool, ...) error
 - type Randomizer
 - type Seed
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Date ¶
Date generates a random time.Time between 1850 and 2050. Only the Day/Month/Year columns are set so that Dates and DateTimes do not cause mismatches in the test data comparisons.
func EnumValue ¶
EnumValue takes an enum field type, parses it's definition to figure out valid values, and selects a random one from within them.
func FormattedString ¶
FormattedString checks a field type to see if it's in a range of special values and if so returns a randomized string for it.
func MediumInt ¶
MediumInt is a special case in mysql (thanks for that -_-) this function checks if the fieldtype matches and if so returns a random value in the proper range.
func StableDBName ¶
StableDBName takes a database name in, and generates a random string using the database name as the rand Seed. getDBNameHash is used to generate unique test database names.
Types ¶
type Randomizer ¶
type Randomizer interface {
	// Randomize should panic if there's no ability to randomize with the current parameters.
	// shouldBeNull is a suggestion that a field should be null in this instance. The randomize implementation
	// can ignore this if the field cannot be null either because the type doesn't support it or there
	// is no ability for a field of this type to be null.
	Randomize(s *Seed, fieldType string, shouldBeNull bool)
}
    Randomizer allows a field to be randomized