forked from acronis/perfkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaker_test.go
50 lines (44 loc) · 1.36 KB
/
faker_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package benchmark
import (
"testing"
)
func TestRandStringBytesWithCardinality(t *testing.T) {
b := New()
b.Randomizer = NewRandomizer(1, 1)
str := b.RandStringBytes(1, "test_", 10, 20, 5, true)
if len(str) < 5 || len(str) > 20 {
t.Errorf("RandStringBytes() error, string length out of bounds")
}
}
func TestRandStringBytesWithoutCardinality(t *testing.T) {
b := New()
b.Randomizer = NewRandomizer(1, 1)
str := b.RandStringBytes(1, "test_", 0, 20, 5, true)
if len(str) < 5 || len(str) > 20 {
t.Errorf("RandStringBytes() error, string length out of bounds")
}
}
func TestGenFakeValueAutoInc(t *testing.T) {
b := New()
b.Randomizer = NewRandomizer(1, 1)
val := b.GenFakeValue(1, "autoinc", "test", 10, 20, 5, nil)
if val == nil {
t.Errorf("GenFakeValue() error, value is nil")
}
}
func TestGenFakeDataWithAutoInc(t *testing.T) {
b := New()
b.Randomizer = NewRandomizer(1, 1)
cols, vals := b.GenFakeData(1, &[]DBFakeColumnConf{{"test", "autoinc", 10, 20, 5}}, true)
if len(cols) != len(vals) {
t.Errorf("GenFakeData() error, columns and values length mismatch")
}
}
func TestGenFakeDataWithoutAutoInc(t *testing.T) {
b := New()
b.Randomizer = NewRandomizer(1, 1)
cols, vals := b.GenFakeData(1, &[]DBFakeColumnConf{{"test", "autoinc", 10, 20, 5}}, false)
if len(cols) != len(vals) {
t.Errorf("GenFakeData() error, columns and values length mismatch")
}
}