Change RandomizeStruct float to single decimal

* Now only uses single decimal precision (0.0-0.9) to avoid conflicting
* with any database decimal constraints and causing data mismatch.
This commit is contained in:
Patrick O'brien 2016-06-11 00:57:59 +10:00
parent e99bb09856
commit 8cc14ce48f

View file

@ -320,9 +320,9 @@ func randomizeField(field reflect.Value) error {
case typeTime:
newVal = randDate()
case typeNullFloat32:
newVal = null.NewFloat32(rand.Float32(), rand.Intn(2) == 1)
newVal = null.NewFloat32(float32(rand.Intn(9))/10.0, rand.Intn(2) == 1)
case typeNullFloat64:
newVal = null.NewFloat64(rand.Float64(), rand.Intn(2) == 1)
newVal = null.NewFloat64(float64(rand.Intn(9))/10.0, rand.Intn(2) == 1)
case typeNullInt:
newVal = null.NewInt(rand.Int(), rand.Intn(2) == 1)
case typeNullInt8:
@ -347,9 +347,9 @@ func randomizeField(field reflect.Value) error {
} else {
switch kind {
case reflect.Float32:
newVal = rand.Float32()
newVal = float32(rand.Intn(9)) / 10.0
case reflect.Float64:
newVal = rand.Float64()
newVal = float64(rand.Intn(9)) / 10.0
case reflect.Int:
newVal = rand.Int()
case reflect.Int8: