MCPcopy
hub / github.com/caddyserver/certmagic / TestRenewLockLeaseDuration

Function TestRenewLockLeaseDuration

config_test.go:96–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestRenewLockLeaseDuration(t *testing.T) {
97 ctx := context.Background()
98 tmpDir, err := os.MkdirTemp(os.TempDir(), "certmagic-test*")
99 testutil.RequireNoError(t, err, "allocating tmp dir")
100 defer os.RemoveAll(tmpDir)
101
102 mockStorage := &mockStorageWithLease{
103 FileStorage: &FileStorage{Path: tmpDir},
104 }
105
106 // Test attempt 0
107 cfg := &Config{Logger: defaultTestLogger}
108 cfg.renewLockLease(ctx, mockStorage, "test-lock", 0)
109 expected := retryIntervals[0] + DefaultACME.CertObtainTimeout
110 testutil.RequireEqual(t, expected, mockStorage.lastDuration)
111
112 // Test attempt beyond array bounds
113 cfg.renewLockLease(ctx, mockStorage, "test-lock", 999)
114 expected = maxRetryDuration + DefaultACME.CertObtainTimeout
115 testutil.RequireEqual(t, expected, mockStorage.lastDuration)
116}
117
118// Test that lease renewal works when storage supports it
119func TestRenewLockLeaseWithInterface(t *testing.T) {

Callers

nothing calls this directly

Calls 3

renewLockLeaseMethod · 0.95
RequireNoErrorFunction · 0.92
RequireEqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…