-
Notifications
You must be signed in to change notification settings - Fork 9
/
misc_test.go
46 lines (40 loc) · 930 Bytes
/
misc_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
package faker_test
import (
"fmt"
"testing"
"github.com/pioz/faker"
"github.com/stretchr/testify/assert"
)
func ExampleBool() {
faker.SetSeed(102)
fmt.Println(faker.Bool())
fmt.Println(faker.Bool())
// Output: true
// false
}
func ExamplePhoneNumber() {
faker.SetSeed(103)
fmt.Println(faker.PhoneNumber())
// Output: 152.380.7298
}
func ExampleUUID() {
faker.SetSeed(104)
fmt.Println(faker.UUID())
// Output: 40abb44c-895e-45b8-9f67-cc02a811744a
}
func TestMiscBuild(t *testing.T) {
faker.SetSeed(500)
s := &struct {
BoolField bool `faker:"bool"`
DefaultBoolField bool
Field1 string `faker:"PhoneNumber"`
Field2 string `faker:"Uuid"`
}{}
err := faker.Build(&s)
assert.Nil(t, err)
t.Log(s)
assert.True(t, s.BoolField)
assert.True(t, s.DefaultBoolField)
assert.Equal(t, "1-740-515-9178", s.Field1)
assert.Equal(t, "05e3b503-b43d-4d23-bca4-224b2e3e12f3", s.Field2)
}