diff --git a/cache_test.go b/cache_test.go index 1dd2252..a3e762e 100644 --- a/cache_test.go +++ b/cache_test.go @@ -7,6 +7,11 @@ import ( func Test_cache_IsExpired(t *testing.T) { cachet := cache{} + + if !cachet.IsExpired() { + t.Error("cache should be expired") + } + if cachet.IsExpired() { cachet.SetData("hello", time.Second*5) } diff --git a/core.go b/core.go index 22687aa..110af5a 100644 --- a/core.go +++ b/core.go @@ -380,8 +380,6 @@ var holidayCache *cache var holidayCacheLock sync.Mutex func GetHolidaysDataWithCache() ([]HolidaysItem, error) { - holidayCacheLock.Lock() - defer holidayCacheLock.Unlock() if holidayCache.IsExpired() { data, err := GetHolidaysData() if err != nil { @@ -392,9 +390,6 @@ func GetHolidaysDataWithCache() ([]HolidaysItem, error) { data := holidayCache.GetData() var result []HolidaysItem err := json.Unmarshal([]byte(data), &result) - if len(data) == 0 { - panic("GetHolidaysDataWithCache json unmarshal error") - } return result, err }