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
+80
View File
@@ -0,0 +1,80 @@
package errors_test
import (
"testing"
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
)
func TestDefaultConfig(t *testing.T) {
config := models.DefaultConfig()
if config.Version != "1.0.0" {
t.Errorf("Version = %q, want %q", config.Version, "1.0.0")
}
if config.DefaultPort != 22 {
t.Errorf("DefaultPort = %d, want 22", config.DefaultPort)
}
if config.ConnectionTimeout != 30 {
t.Errorf("ConnectionTimeout = %d, want 30", config.ConnectionTimeout)
}
if config.Theme != "dark" {
t.Errorf("Theme = %q, want %q", config.Theme, "dark")
}
if len(config.Profiles) != 1 {
t.Errorf("Profiles has %d items, want 1", len(config.Profiles))
}
if config.ActiveProfile != "default" {
t.Errorf("ActiveProfile = %q, want %q", config.ActiveProfile, "default")
}
}
func TestAppConfigProfiles(t *testing.T) {
config := models.DefaultConfig()
// Test GetProfile
profile := config.GetProfile("default")
if profile == nil {
t.Fatal("GetProfile(default) returned nil")
}
if profile.Name != "default" {
t.Errorf("Profile.Name = %q, want %q", profile.Name, "default")
}
// Test GetProfile for non-existent profile
profile = config.GetProfile("nonexistent")
if profile != nil {
t.Error("GetProfile(nonexistent) should return nil")
}
// Test GetActiveProfile
profile = config.GetActiveProfile()
if profile == nil {
t.Fatal("GetActiveProfile() returned nil")
}
if profile.Name != "default" {
t.Errorf("Active profile Name = %q, want %q", profile.Name, "default")
}
// Test AddProfile
newProfile := models.Profile{
Name: "work",
Theme: "light",
}
config.AddProfile(newProfile)
if len(config.Profiles) != 2 {
t.Errorf("After AddProfile, Profiles has %d items, want 2", len(config.Profiles))
}
// Test RemoveProfile
config.RemoveProfile("work")
if len(config.Profiles) != 1 {
t.Errorf("After RemoveProfile, Profiles has %d items, want 1", len(config.Profiles))
}
// Test RemoveProfile for non-existent profile
config.RemoveProfile("nonexistent")
if len(config.Profiles) != 1 {
t.Errorf("After RemoveProfile(nonexistent), Profiles has %d items, want 1", len(config.Profiles))
}
}