mirror of
https://github.com/henrygd/beszel.git
synced 2026-08-19 08:47:46 +02:00
systems: synthesize error when getRecord returns nil record (#1968)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user