-
Notifications
You must be signed in to change notification settings - Fork 11
/
utils_test.go
121 lines (107 loc) · 3.12 KB
/
utils_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package faker_test
import (
"testing"
"time"
"github.com/pioz/faker"
"github.com/stretchr/testify/assert"
)
func TestParamsToMinMaxIntInvaliParams1(t *testing.T) {
faker.SetSeed(700)
s := &struct {
IntField int `faker:"IntInRange"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters", err.Error())
}
func TestParamsToMinMaxIntInvaliParams2(t *testing.T) {
faker.SetSeed(700)
s := &struct {
IntField int `faker:"IntInRange(1)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters", err.Error())
}
func TestParamsToMinMaxIntInvaliParams3(t *testing.T) {
faker.SetSeed(700)
s := &struct {
IntField int `faker:"IntInRange(a,b)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: strconv.Atoi: parsing \"a\": invalid syntax", err.Error())
}
func TestParamsToMinMaxIntInvaliParams4(t *testing.T) {
faker.SetSeed(700)
s := &struct {
IntField int `faker:"IntInRange(1,b)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: strconv.Atoi: parsing \"b\": invalid syntax", err.Error())
}
func TestParamsToMinMaxFloat64InvaliParams1(t *testing.T) {
s := &struct {
Field float64 `faker:"Float64InRange"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters", err.Error())
}
func TestParamsToMinMaxFloat64InvaliParams2(t *testing.T) {
s := &struct {
Field float64 `faker:"Float64InRange(1.0,b)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: strconv.ParseFloat: parsing \"b\": invalid syntax", err.Error())
}
func TestParamsToMinMaxFloat64InvaliParams3(t *testing.T) {
s := &struct {
Field float64 `faker:"Float64InRange(a,2)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: strconv.ParseFloat: parsing \"a\": invalid syntax", err.Error())
}
func TestParamsToMinMaxDurationInvalidParams1(t *testing.T) {
s := &struct {
Field time.Duration `faker:"DurationInRange"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters", err.Error())
}
func TestParamsToMinMaxDurationInvalidParams2(t *testing.T) {
s := &struct {
Field time.Duration `faker:"DurationInRange(2s,b)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: time: invalid duration \"b\"", err.Error())
}
func TestParamsToMinMaxDurationInvalidParams3(t *testing.T) {
s := &struct {
Field time.Duration `faker:"DurationInRange(a,2ms)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: time: invalid duration \"a\"", err.Error())
}
func TestParamsToIntInvalidParams1(t *testing.T) {
s := &struct {
Field string `faker:"StringWithSize"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters", err.Error())
}
func TestParamsToIntInvalidParams2(t *testing.T) {
s := &struct {
Field string `faker:"StringWithSize(a)"`
}{}
err := faker.Build(&s)
assert.NotNil(t, err)
assert.Equal(t, "invalid parameters: strconv.Atoi: parsing \"a\": invalid syntax", err.Error())
}