mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-09 07:19:08 -06:00
Fix failing integration tests by clearing cache properly
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
This commit is contained in:
@@ -2100,6 +2100,9 @@ func TestApiGetPropertyDisabled(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Clear cache so the next request fetches fresh data from DB
|
||||
cache.Delete(ctx, db.PropertyByIDCacheKey(property.ID))
|
||||
|
||||
// Try to get the disabled property
|
||||
_, meta, err = requestResponseAPISuite[*apiPropertyOutput](ctx, nil,
|
||||
http.MethodGet,
|
||||
|
||||
@@ -390,8 +390,12 @@ func TestGetPuzzleDisabledProperty(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Clear cache so we fetch fresh data
|
||||
// Clear cache and reload the property from DB so it has Enabled: false
|
||||
cache.Delete(ctx, db.PropertyBySitekeyCacheKey(sitekey))
|
||||
_, err = store.Impl().RetrievePropertyBySitekey(ctx, sitekey)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Now the puzzle request should be forbidden
|
||||
resp, err = puzzleSuite(ctx, sitekey, property.Domain)
|
||||
|
||||
@@ -338,6 +338,9 @@ func orgPropertiesCacheKey(orgID int32, key string) CacheKey {
|
||||
func propertyByIDCacheKey(propID int32) CacheKey {
|
||||
return Int32CacheKey(propertyByIDCacheKeyPrefix, propID)
|
||||
}
|
||||
func PropertyByIDCacheKey(propID int32) CacheKey {
|
||||
return Int32CacheKey(propertyByIDCacheKeyPrefix, propID)
|
||||
}
|
||||
func PropertyBySitekeyCacheKey(sitekey string) CacheKey {
|
||||
return StringCacheKey(propertyBySitekeyCacheKeyPrefix, sitekey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user