refactor: move V1 code into v1/ subdirectory

- git mv cmd/ internal/ pkg/ test/ go.mod go.sum Makefile build.sh docs/ v1/
- Create v1/README.md with V1 documentation
- Update root README for V1 + V2 structure
- V1 still builds (cd v1 && go build ./cmd/hostkeeper) and 105 tests pass
- Root is now clean for V2 development
This commit is contained in:
swanadiva
2026-07-07 11:56:27 +07:00
parent 8ebdebedc8
commit 847989df75
68 changed files with 58 additions and 116 deletions
+95
View File
@@ -0,0 +1,95 @@
package tui_test
import (
"testing"
"time"
"git.tukangketik.id/swanadiva/hostkeeper/pkg/tui"
)
func TestErrorBannerShowHide(t *testing.T) {
banner := tui.NewErrorBanner(tui.SevError)
// Initially not visible
if banner.IsVisible() {
t.Error("Banner should not be visible initially")
}
// Show the banner
banner.Show("Test Error", "Something went wrong", "Check logs", "Restart app")
if !banner.IsVisible() {
t.Error("Banner should be visible after Show()")
}
// Verify content
if banner.Title != "Test Error" {
t.Errorf("Title = %q, want %q", banner.Title, "Test Error")
}
if banner.Detail != "Something went wrong" {
t.Errorf("Detail = %q, want %q", banner.Detail, "Something went wrong")
}
if len(banner.Hints) != 2 {
t.Errorf("Hints has %d items, want 2", len(banner.Hints))
}
// Hide the banner
banner.Hide()
if banner.IsVisible() {
t.Error("Banner should not be visible after Hide()")
}
}
func TestErrorBannerAutoDismiss(t *testing.T) {
banner := tui.NewErrorBanner(tui.SevWarning)
banner.AutoDismiss = true
banner.DismissAfter = 100 * time.Millisecond
banner.Show("Test Warning", "Something")
if !banner.IsVisible() {
t.Error("Banner should be visible after Show()")
}
// Wait for auto-dismiss
time.Sleep(150 * time.Millisecond)
banner.Update()
if banner.IsVisible() {
t.Error("Banner should be auto-dismissed after delay")
}
}
func TestErrorBannerSeverity(t *testing.T) {
tests := []struct {
severity tui.ErrorSeverity
name string
}{
{tui.SevError, "error"},
{tui.SevWarning, "warning"},
{tui.SevInfo, "info"},
}
for _, tt := range tests {
banner := tui.NewErrorBanner(tt.severity)
if banner.Severity != tt.severity {
t.Errorf("NewErrorBanner(%v).Severity = %v, want %v", tt.name, banner.Severity, tt.severity)
}
}
}
func TestErrorBannerView(t *testing.T) {
banner := tui.NewErrorBanner(tui.SevError)
banner.Show("Error Title", "Error detail", "Hint 1", "Hint 2")
// Test that View returns non-empty string
output := banner.View(80)
if output == "" {
t.Error("View() returned empty string")
}
// Test that View returns empty string when not visible
banner.Hide()
output = banner.View(80)
if output != "" {
t.Error("View() should return empty string when not visible")
}
}