* fix(beads): cache version check and add timeout to prevent cli lag
* fix(mail_queue): add nil check for queue config
Prevents potential nil pointer panic when queue config exists
in map but has nil value. Added || queueCfg == nil check to
the queue lookup condition in runMailClaim function.
Fixes potential panic that could occur if a queue entry exists
in config but with a nil value.
* fix(migrate_agents_test): fix icon expectations to match actual output
The printMigrationResult function uses icons with two leading spaces
(" ✓", " ⊘", " ✗") but the test expected icons without spaces.
This fixes the test expectations to match the actual output format.
* fix(hook): handle error from events.LogFeed
Previously the error from LogFeed was silently ignored with _.
Now we log the error to stderr at warning level but don't fail
the operation since the primary hook action succeeded.
96 lines
2.0 KiB
Go
96 lines
2.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/steveyegge/gastown/internal/beads"
|
|
)
|
|
|
|
func TestMigrationResultStatus(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
result migrationResult
|
|
wantIcon string
|
|
}{
|
|
{
|
|
name: "migrated shows checkmark",
|
|
result: migrationResult{
|
|
OldID: "gt-mayor",
|
|
NewID: "hq-mayor",
|
|
Status: "migrated",
|
|
Message: "successfully migrated",
|
|
},
|
|
wantIcon: " ✓",
|
|
},
|
|
{
|
|
name: "would migrate shows checkmark",
|
|
result: migrationResult{
|
|
OldID: "gt-mayor",
|
|
NewID: "hq-mayor",
|
|
Status: "would migrate",
|
|
Message: "would copy state from gt-mayor",
|
|
},
|
|
wantIcon: " ✓",
|
|
},
|
|
{
|
|
name: "skipped shows empty circle",
|
|
result: migrationResult{
|
|
OldID: "gt-mayor",
|
|
NewID: "hq-mayor",
|
|
Status: "skipped",
|
|
Message: "already exists",
|
|
},
|
|
wantIcon: " ⊘",
|
|
},
|
|
{
|
|
name: "error shows X",
|
|
result: migrationResult{
|
|
OldID: "gt-mayor",
|
|
NewID: "hq-mayor",
|
|
Status: "error",
|
|
Message: "failed to create",
|
|
},
|
|
wantIcon: " ✗",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
var icon string
|
|
switch tt.result.Status {
|
|
case "migrated", "would migrate":
|
|
icon = " ✓"
|
|
case "skipped":
|
|
icon = " ⊘"
|
|
case "error":
|
|
icon = " ✗"
|
|
}
|
|
if icon != tt.wantIcon {
|
|
t.Errorf("icon for status %q = %q, want %q", tt.result.Status, icon, tt.wantIcon)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestTownBeadIDHelpers(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
got string
|
|
want string
|
|
}{
|
|
{"MayorBeadIDTown", beads.MayorBeadIDTown(), "hq-mayor"},
|
|
{"DeaconBeadIDTown", beads.DeaconBeadIDTown(), "hq-deacon"},
|
|
{"DogBeadIDTown", beads.DogBeadIDTown("fido"), "hq-dog-fido"},
|
|
{"RoleBeadIDTown mayor", beads.RoleBeadIDTown("mayor"), "hq-mayor-role"},
|
|
{"RoleBeadIDTown witness", beads.RoleBeadIDTown("witness"), "hq-witness-role"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if tt.got != tt.want {
|
|
t.Errorf("%s = %q, want %q", tt.name, tt.got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|