-
Notifications
You must be signed in to change notification settings - Fork 11
/
country_test.go
58 lines (50 loc) · 1.16 KB
/
country_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
package faker_test
import (
"fmt"
"testing"
"github.com/pioz/faker"
"github.com/stretchr/testify/assert"
)
func ExampleCountryName() {
faker.SetSeed(1000)
fmt.Println(faker.CountryName())
// Output: Rwanda
}
func ExampleCountryAlpha2() {
faker.SetSeed(1001)
fmt.Println(faker.CountryAlpha2())
// Output: ML
}
func ExampleCountryAlpha3() {
faker.SetSeed(1002)
fmt.Println(faker.CountryAlpha3())
// Output: TKM
}
func ExampleCountryNationality() {
faker.SetSeed(1002)
fmt.Println(faker.CountryNationality())
// Output: Venezuelan
}
func ExampleCountryFlag() {
faker.SetSeed(1003)
fmt.Println(faker.CountryFlag())
// Output: 🇳🇷
}
func TestCountryBuild(t *testing.T) {
faker.SetSeed(1010)
s := &struct {
Field1 string `faker:"CountryName"`
Field2 string `faker:"CountryAlpha2"`
Field3 string `faker:"CountryAlpha3"`
Field4 string `faker:"CountryNationality"`
Field5 string `faker:"CountryFlag"`
}{}
err := faker.Build(&s)
assert.Nil(t, err)
t.Log(s)
assert.Equal(t, "Iceland", s.Field1)
assert.Equal(t, "IN", s.Field2)
assert.Equal(t, "RUS", s.Field3)
assert.Equal(t, "Cocos Islander", s.Field4)
assert.Equal(t, "🇲🇹", s.Field5)
}