Skip to content

Commit ce140d7

Browse files
committed
test: Add test cases without timezone
1 parent 285160b commit ce140d7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

traveler_unit_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ func (s *TravelerSuite) TearDownTest() {
2020
}
2121

2222
func (s *TravelerSuite) TestNow() {
23+
s.Run("without timezone", func() {
24+
s.Equal(time.Now().Format(DateLayout), Now().Layout(DateLayout, Local))
25+
})
26+
2327
s.Run("error timezone", func() {
2428
s.Error(Now("xxx").Error)
2529
s.Empty(Now("xxx").ToString())
2630
})
2731

2832
s.Run("valid timezone", func() {
29-
s.Equal(time.Now().Format(DateLayout), Now().Layout(DateLayout, Local))
3033
s.Equal(time.Now().In(time.UTC).Format(DateLayout), Now(UTC).Layout(DateLayout))
3134
})
3235

@@ -38,13 +41,16 @@ func (s *TravelerSuite) TestNow() {
3841
}
3942

4043
func (s *TravelerSuite) TestTomorrow() {
44+
s.Run("without timezone", func() {
45+
s.Equal(time.Now().Add(time.Hour*24).Format(DateLayout), Tomorrow().Layout(DateLayout, Local))
46+
})
47+
4148
s.Run("error timezone", func() {
4249
s.Error(Tomorrow("xxx").Error)
4350
s.Empty(Tomorrow("xxx").ToString())
4451
})
4552

4653
s.Run("valid timezone", func() {
47-
s.Equal(time.Now().Add(time.Hour*24).Format(DateLayout), Tomorrow().Layout(DateLayout, Local))
4854
s.Equal(time.Now().Add(time.Hour*24).In(time.UTC).Format(DateLayout), Tomorrow(UTC).Layout(DateLayout))
4955
})
5056

@@ -56,13 +62,16 @@ func (s *TravelerSuite) TestTomorrow() {
5662
}
5763

5864
func (s *TravelerSuite) TestYesterday() {
65+
s.Run("without timezone", func() {
66+
s.Equal(time.Now().Add(time.Hour*-24).Format(DateLayout), Yesterday().Layout(DateLayout, Local))
67+
})
68+
5969
s.Run("error timezone", func() {
6070
s.Error(Yesterday("xxx").Error)
6171
s.Empty(Yesterday("xxx").ToString())
6272
})
6373

6474
s.Run("valid timezone", func() {
65-
s.Equal(time.Now().Add(time.Hour*-24).Format(DateLayout), Yesterday().Layout(DateLayout, Local))
6675
s.Equal(time.Now().Add(time.Hour*-24).In(time.UTC).Format(DateLayout), Yesterday(UTC).Layout(DateLayout))
6776
})
6877

0 commit comments

Comments
 (0)