systems: synthesize error when getRecord returns nil record (#1968)

This commit is contained in:
Sai Asish Y
2026-08-16 11:44:30 -07:00
committed by GitHub
parent 1ab1229a61
commit adaf6f338d
2 changed files with 24 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
package systems
import (
"context"
"testing"
"github.com/henrygd/beszel/internal/entities/system"
@@ -157,3 +158,17 @@ func TestCombinedData_MigrateDeprecatedFields(t *testing.T) {
}
})
}
func TestSetDownAfterContextCancelled(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
// manager is nil on purpose: setDown must bail out before touching the app
sys := &System{Status: up, ctx: ctx}
if err := sys.setDown(nil); err != context.Canceled {
t.Fatalf("expected context.Canceled, got %v", err)
}
if sys.Status != up {
t.Fatalf("status should be untouched, got %q", sys.Status)
}
}