fix(api): 管理后台成功写入后递增缓存代次 (#40)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Vendored
+11
-7
@@ -22,6 +22,15 @@ func TestDisabledFailsOpen(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBumpDisabledCache(t *testing.T) {
|
||||
if err := (*Cache)(nil).Bump(context.Background()); err != nil {
|
||||
t.Fatalf("nil cache Bump(): %v", err)
|
||||
}
|
||||
if err := (&Cache{}).Bump(context.Background()); err != nil {
|
||||
t.Fatalf("disabled cache Bump(): %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testCache(t *testing.T) *Cache {
|
||||
t.Helper()
|
||||
url := os.Getenv("OPENGOODS_REDIS_URL")
|
||||
@@ -69,14 +78,9 @@ func TestEpochInvalidation(t *testing.T) {
|
||||
t.Fatal("expected hit before epoch bump")
|
||||
}
|
||||
|
||||
// Simulate an ingestion write bumping the global epoch.
|
||||
if err := c.rdb.Incr(ctx, epochKey).Err(); err != nil {
|
||||
t.Fatalf("incr epoch: %v", err)
|
||||
if err := c.Bump(ctx); err != nil {
|
||||
t.Fatalf("bump epoch: %v", err)
|
||||
}
|
||||
// Force the process to re-read the epoch rather than use its cached value.
|
||||
c.mu.Lock()
|
||||
c.epochOK = false
|
||||
c.mu.Unlock()
|
||||
|
||||
if c.GetJSON(ctx, suffix, &dst) {
|
||||
t.Fatal("entry should be invisible after epoch bump")
|
||||
|
||||
Reference in New Issue
Block a user