This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdate_test.go
84 lines (76 loc) · 1.6 KB
/
date_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
package faker_test
import (
"testing"
"time"
"github.com/neotoolkit/faker"
)
func TestFaker_Weekday(t *testing.T) {
t.Parallel()
f := faker.New(faker.WithWeekdays("test"))
weekday := f.Weekday()
if weekday != "test" {
t.Errorf("got %s, want test", weekday)
}
}
func TestWeekday(t *testing.T) {
t.Parallel()
weekdays := map[string]struct{}{
"Sunday": {},
"Monday": {},
"Tuesday": {},
"Wednesday": {},
"Thursday": {},
"Friday": {},
"Saturday": {},
}
weekday := faker.Weekday()
if _, ok := weekdays[weekday]; !ok {
t.Error("bad weekday")
}
}
func TestFaker_Month(t *testing.T) {
t.Parallel()
f := faker.New(faker.WithMonths("test"))
month := f.Month()
if month != "test" {
t.Errorf("got %s, want test", month)
}
}
func TestMonth(t *testing.T) {
t.Parallel()
months := map[string]struct{}{
"January": {},
"February": {},
"March": {},
"April": {},
"May": {},
"June": {},
"July": {},
"August": {},
"September": {},
"October": {},
"November": {},
"December": {},
}
month := faker.Month()
if _, ok := months[month]; !ok {
t.Error("bad month")
}
}
func TestFaker_Year(t *testing.T) {
t.Parallel()
f := faker.New()
year := f.Year()
currentYear := time.Now().Year()
if year < 1970 || year > currentYear {
t.Error("year must be equal or greater 1970 or equal or less current local year")
}
}
func TestYear(t *testing.T) {
t.Parallel()
year := faker.Year()
currentYear := time.Now().Year()
if year < 1970 || year > currentYear {
t.Error("year must be equal or greater 1970 or equal or less current local year")
}
}