Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions internal/service/service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package service

import (
"reflect"
"testing"
)

func TestNewManager(t *testing.T) {
variant := Variant{
ID: "test-id",
Family: "test-family",
Variant: "Local",
RegistryName: "TestService",
DisplayName: "Test Service Display",
ExeName: "test.exe",
Binary: []byte("test binary data"),
}

manager := NewManager(variant)

if manager == nil {
t.Fatal("NewManager returned nil")
}

if !reflect.DeepEqual(manager.variant, variant) {
t.Errorf("NewManager() = %v, want variant %v", manager.variant, variant)
}
}
22 changes: 11 additions & 11 deletions internal/ui/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ func buildFamilyMenuItems(fs service.FamilyStatus) []list.Item {
data: "install-remote",
},
menuItem{
title: "Volver",
title: LabelBack,
description: "Regresar al menΓΊ principal",
icon: "[<]",
data: "back",
icon: IconBack,
data: ActionBack,
},
}
}
Expand Down Expand Up @@ -130,15 +130,15 @@ func buildFamilyMenuItems(fs service.FamilyStatus) []list.Item {
title: "Forzar DetenciΓ³n",
description: "El servicio estΓ‘ en transiciΓ³n β€” forzar detenciΓ³n",
icon: "[!]",
data: "force-stop",
data: ActionForceStop,
})

case service.StatusUnknown:
items = append(items, menuItem{
title: "Forzar DetenciΓ³n",
description: "Estado desconocido β€” intentar forzar detenciΓ³n del servicio",
icon: "[!]",
data: "force-stop",
data: ActionForceStop,
})
default:
log.Printf("Estado inesperado para %s: %s", installed, status.String())
Expand All @@ -159,10 +159,10 @@ func buildFamilyMenuItems(fs service.FamilyStatus) []list.Item {
data: "uninstall",
},
menuItem{
title: "Volver",
title: LabelBack,
description: "Regresar al menΓΊ principal",
icon: "[<]",
data: "back",
icon: IconBack,
data: ActionBack,
},
)

Expand All @@ -189,10 +189,10 @@ func buildLogsMenuItems() []list.Item {
data: "open-dir",
},
menuItem{
title: "Volver",
title: LabelBack,
description: "Regresar al menΓΊ de servicio",
icon: "[<]",
data: "back",
icon: IconBack,
data: ActionBack,
},
}
}
13 changes: 13 additions & 0 deletions internal/ui/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ui

// Shared constants for UI menu actions and labels to prevent goconst warnings.
const (
// ActionBack is the data string used for navigating back.
ActionBack = "back"
// ActionForceStop is the data string used for forcing a service to stop.
ActionForceStop = "force-stop"
// LabelBack is the display title for back navigation options.
LabelBack = "Volver"
// IconBack is the standard icon used for back navigation options.
IconBack = "[<]"
)
6 changes: 3 additions & 3 deletions internal/ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (m Model) handleFamilyKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}

switch selected.data {
case "back":
case ActionBack:
return m.goToDashboard()

case "install-local":
Expand All @@ -236,7 +236,7 @@ func (m Model) handleFamilyKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
return m.executeAction("Detener Servicio", mgr.Stop)

case "force-stop":
case ActionForceStop:
mgr := m.getActiveManager()
if mgr == nil {
m.statusMessage = "No se pudo determinar el servicio a detener."
Expand Down Expand Up @@ -313,7 +313,7 @@ func (m Model) handleLogsKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
m.statusMessage = "Abriendo carpeta de logs..."
return m, nil

case "back":
case ActionBack:
return m.returnToFamilyMenu()
}
}
Expand Down
Loading