Push: Initial push
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
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