-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig_sequence_test.go
More file actions
58 lines (46 loc) · 1.84 KB
/
config_sequence_test.go
File metadata and controls
58 lines (46 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package reverseproxy
import (
"testing"
"time"
)
// TestSequentialCacheScenarios simulates running Response caching followed by Cache TTL behavior
func TestSequentialCacheScenarios(t *testing.T) {
ctx := &ReverseProxyBDDTestContext{}
t.Run("Response_caching_scenario", func(t *testing.T) {
// This is the Given step from "Response caching" scenario
err := ctx.iHaveAReverseProxyWithCachingEnabled()
if err != nil {
t.Fatalf("Response caching Given failed: %v", err)
}
t.Logf("After Response caching Given: CacheTTL = %v", ctx.config.CacheTTL)
// CacheTTL is set to 337s as a signature to identify this scenario (see bdd_caching_tenant_test.go:43)
if ctx.config.CacheTTL != 337*time.Second {
t.Errorf("Expected CacheTTL=337s for Response caching (signature value), got %v", ctx.config.CacheTTL)
}
// Cleanup after this scenario (simulating what happens between scenarios)
ctx.resetContext()
t.Logf("After resetContext: ctx.config = %v", ctx.config)
})
t.Run("Cache_TTL_behavior_scenario", func(t *testing.T) {
// This is the Given step from "Cache TTL behavior" scenario
err := ctx.iHaveAReverseProxyWithSpecificCacheTTLConfigured()
if err != nil {
t.Fatalf("Cache TTL behavior Given failed: %v", err)
}
t.Logf("After Cache TTL Given: CacheTTL = %v", ctx.config.CacheTTL)
if ctx.config.CacheTTL != 1*time.Second {
t.Errorf("❌ LEAK DETECTED: Expected CacheTTL=1s, got %v", ctx.config.CacheTTL)
t.Errorf("This means resetContext() didn't fully isolate the scenarios!")
} else {
t.Logf("✅ CacheTTL is correct (1s)")
}
// Check what the When step would see
ttl := ctx.config.CacheTTL
waitTime := ttl + (500 * time.Millisecond)
t.Logf("When step would sleep for: %v", waitTime)
if waitTime > 2*time.Second {
t.Errorf("❌ Would sleep for %v which is too long!", waitTime)
}
ctx.resetContext()
})
}