Skip to content

Commit

Permalink
Merge pull request #21 from kenshin579/feat/#20-not
Browse files Browse the repository at this point in the history
[#20] not to caching even if the updatedAt has a default time value
  • Loading branch information
kenshin579 authored Jul 16, 2023
2 parents 4731aac + 3d44e21 commit c0e9e12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func isMapEmpty(m map[string]any) bool {
for _, v := range m {
switch val := v.(type) {
case string:
if val != "" {
if val != "" && val != "0001-01-01T00:00:00Z" {
return false
}
case int:
Expand Down
2 changes: 2 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func Test_isAllFieldsEmpty(t *testing.T) {
City string `json:"city"`
Zip int `json:"zip"`
} `json:"address"`
UpdatedAt time.Time `json:"updatedAt"`
}

p1 := person{
Expand Down Expand Up @@ -323,6 +324,7 @@ func Test_isAllFieldsEmpty(t *testing.T) {
assert.False(t, isAllFieldsEmpty([]byte(`{"a":"","b":"b","c":0}`)))
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0}`)))
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0.0}`)))
assert.True(t, isAllFieldsEmpty([]byte(`{"a":"","b":"","c":0.0,"updatedAt":"0001-01-01T00:00:00Z"}`)))
}

func Test_isIncludePaths(t *testing.T) {
Expand Down

0 comments on commit c0e9e12

Please sign in to comment.