Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix grant refresh callback race test

rcourtman166b4768dbc9
diff --git a/pkg/licensing/grant_refresh_test.go b/pkg/licensing/grant_refresh_test.go
index 4dad873a66..57d6083398 100644
--- a/pkg/licensing/grant_refresh_test.go
+++ b/pkg/licensing/grant_refresh_test.go
@@ -141,9 +141,11 @@ func TestGrantRefreshLoop_401ClearsActivation(t *testing.T) {
svc := NewService()
svc.SetLicenseServerClient(NewLicenseServerClient(server.URL))
svc.SetPersistence(p)
- var callbackState *ActivationState
+ var callbackState atomic.Pointer[ActivationState]
+ var callbackCalled atomic.Bool
svc.SetActivationStateChangeCallback(func(state *ActivationState) {
- callbackState = state
+ callbackCalled.Store(true)
+ callbackState.Store(state)
})
state := &ActivationState{
@@ -202,8 +204,11 @@ func TestGrantRefreshLoop_401ClearsActivation(t *testing.T) {
if svc.IsActivated() {
t.Error("expected activation cleared after 401 revocation")
}
- if callbackState != nil {
- t.Fatalf("expected nil activation-state callback after 401 revocation, got %+v", callbackState)
+ if !callbackCalled.Load() {
+ t.Fatal("expected activation-state callback after 401 revocation")
+ }
+ if state := callbackState.Load(); state != nil {
+ t.Fatalf("expected nil activation-state callback after 401 revocation, got %+v", state)
}
// Verify the persisted state was also cleared.