Del: Update
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
// Package mock provides predefined appliance states for prototype validation.
|
||||
package mock
|
||||
|
||||
import (
|
||||
"github.com/nebara/nebara-os/internal/model"
|
||||
)
|
||||
|
||||
// State bundles all data required to render a complete TUI screen.
|
||||
type State struct {
|
||||
Appliance model.ApplianceInfo
|
||||
Message *model.SystemMessage
|
||||
InitialMenu int // zero-based index into model.MainMenu()
|
||||
}
|
||||
|
||||
// WarningState reproduces Figma mock state A.
|
||||
func WarningState() State {
|
||||
return State{
|
||||
Appliance: model.ApplianceInfo{
|
||||
ProductName: "Nebara S3GX Appliance",
|
||||
Version: "1.0.1",
|
||||
Hostname: "jkt-s3gx-lin-01.domain.local",
|
||||
Address: "10.249.23.13/26",
|
||||
Uptime: "132d 12h 32m",
|
||||
Status: "Healthy",
|
||||
},
|
||||
Message: &model.SystemMessage{
|
||||
Severity: model.SeverityWarning,
|
||||
Text: "[Warn] Update Available to version 2.1.4!",
|
||||
},
|
||||
InitialMenu: 2, // Security & Access
|
||||
}
|
||||
}
|
||||
|
||||
// NormalState reproduces Figma mock state B.
|
||||
func NormalState() State {
|
||||
return State{
|
||||
Appliance: model.ApplianceInfo{
|
||||
ProductName: "Nebara S3GX Appliance",
|
||||
Version: "2.1.4",
|
||||
Hostname: "sin-s3gx-lin-05.domain.local",
|
||||
Address: "10.175.15.11/25",
|
||||
Uptime: "111d 14h 21m",
|
||||
Status: "Healthy",
|
||||
},
|
||||
Message: nil,
|
||||
InitialMenu: 3, // System Maintenance
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package mock_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nebara/nebara-os/internal/mock"
|
||||
"github.com/nebara/nebara-os/internal/model"
|
||||
)
|
||||
|
||||
func TestWarningState(t *testing.T) {
|
||||
s := mock.WarningState()
|
||||
|
||||
if s.Appliance.ProductName == "" {
|
||||
t.Error("ProductName should not be empty")
|
||||
}
|
||||
if s.Appliance.Version != "1.0.1" {
|
||||
t.Errorf("expected version 1.0.1, got %s", s.Appliance.Version)
|
||||
}
|
||||
if s.Message == nil {
|
||||
t.Fatal("warning state should have a message")
|
||||
}
|
||||
if s.Message.Severity != model.SeverityWarning {
|
||||
t.Error("expected SeverityWarning")
|
||||
}
|
||||
if !s.Message.IsVisible() {
|
||||
t.Error("warning message should be visible")
|
||||
}
|
||||
if s.InitialMenu < 0 || s.InitialMenu >= 6 {
|
||||
t.Errorf("InitialMenu out of range: %d", s.InitialMenu)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalState(t *testing.T) {
|
||||
s := mock.NormalState()
|
||||
|
||||
if s.Appliance.ProductName == "" {
|
||||
t.Error("ProductName should not be empty")
|
||||
}
|
||||
if s.Appliance.Version != "2.1.4" {
|
||||
t.Errorf("expected version 2.1.4, got %s", s.Appliance.Version)
|
||||
}
|
||||
if s.Message != nil && s.Message.IsVisible() {
|
||||
t.Error("normal state should have no visible message")
|
||||
}
|
||||
if s.InitialMenu < 0 || s.InitialMenu >= 6 {
|
||||
t.Errorf("InitialMenu out of range: %d", s.InitialMenu)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWarningState_CorrectMenuSelection(t *testing.T) {
|
||||
s := mock.WarningState()
|
||||
menu := model.MainMenu()
|
||||
if s.InitialMenu >= len(menu) {
|
||||
t.Fatalf("InitialMenu %d exceeds menu length %d", s.InitialMenu, len(menu))
|
||||
}
|
||||
if menu[s.InitialMenu].Label != "Security & Access" {
|
||||
t.Errorf("warning state should select 'Security & Access', got %q", menu[s.InitialMenu].Label)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalState_CorrectMenuSelection(t *testing.T) {
|
||||
s := mock.NormalState()
|
||||
menu := model.MainMenu()
|
||||
if s.InitialMenu >= len(menu) {
|
||||
t.Fatalf("InitialMenu %d exceeds menu length %d", s.InitialMenu, len(menu))
|
||||
}
|
||||
if menu[s.InitialMenu].Label != "System Maintenance" {
|
||||
t.Errorf("normal state should select 'System Maintenance', got %q", menu[s.InitialMenu].Label)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSystemMessage_IsVisible_Nil(t *testing.T) {
|
||||
var m *model.SystemMessage
|
||||
if m.IsVisible() {
|
||||
t.Error("nil message should not be visible")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSystemMessage_IsVisible_Empty(t *testing.T) {
|
||||
m := &model.SystemMessage{Severity: model.SeverityWarning, Text: ""}
|
||||
if m.IsVisible() {
|
||||
t.Error("empty text message should not be visible")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSystemMessage_IsVisible_SeverityNone(t *testing.T) {
|
||||
m := &model.SystemMessage{Severity: model.SeverityNone, Text: "some text"}
|
||||
if m.IsVisible() {
|
||||
t.Error("SeverityNone message should not be visible")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user