Skip to content

Commit

Permalink
🐛 fix: fix unit tests error for string to time convert
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 5, 2024
1 parent 2d942e7 commit acd953c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions converters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,22 @@ func TestEscape(t *testing.T) {
func TestStrToTime(t *testing.T) {
is := assert.New(t)
tests := map[string]string{
"20180927": "2018-09-27 00:00:00 +0800 CST",
"2018-09-27": "2018-09-27 00:00:00 +0800 CST",
"2018-09-27 12": "2018-09-27 12:00:00 +0800 CST",
"2018-09-27T12": "2018-09-27 12:00:00 +0800 CST",
"2018-09-27 12:34": "2018-09-27 12:34:00 +0800 CST",
"2018-09-27T12:34": "2018-09-27 12:34:00 +0800 CST",
"2018-09-27 12:34:45": "2018-09-27 12:34:45 +0800 CST",
"2018-09-27T12:34:45": "2018-09-27 12:34:45 +0800 CST",
"2018/09/27 12:34:45": "2018-09-27 12:34:45 +0800 CST",
"2018/09/27T12:34:45Z": "2018-09-27 12:34:45 +0800 CST",
"20180927": "2018-09-27 00:00:00",
"2018-09-27": "2018-09-27 00:00:00",
"2018-09-27 12": "2018-09-27 12:00:00",
"2018-09-27T12": "2018-09-27 12:00:00",
"2018-09-27 12:34": "2018-09-27 12:34:00",
"2018-09-27T12:34": "2018-09-27 12:34:00",
"2018-09-27 12:34:45": "2018-09-27 12:34:45",
"2018-09-27T12:34:45": "2018-09-27 12:34:45",
"2018/09/27 12:34:45": "2018-09-27 12:34:45",
"2018/09/27T12:34:45Z": "2018-09-27 12:34:45",
}

for sample, want := range tests {
tm, err := StrToTime(sample)
is.Nil(err)
is.Eq(want, tm.String())
is.StrContains(tm.String(), want)
}

tm, err := StrToTime("invalid")
Expand Down
2 changes: 1 addition & 1 deletion filtration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TestFiltration_Filtering(t *testing.T) {

sTime, ok := f.Safe("sDate")
is.True(ok)
is.Eq("2018-10-16 12:34:00 +0800 CST", fmt.Sprintf("%v", sTime))
is.StrContains(fmt.Sprintf("%v", sTime), "2018-10-16 12:34:00")

data["url"] = "a.com?p=1"
f = New(data)
Expand Down

0 comments on commit acd953c

Please sign in to comment.