Files
pad/internal/items/migrate_test.go
T
xarmian 7cda0d7896 feat: rebrand to Perpetual Software + new tagline (IDEA-832) (#273)
Migrates from xarmian/pad to PerpetualSoftware/pad across the entire
repo and updates the product subtitle to "Collaborate with your AI
agents".

Go module rename
- go.mod: github.com/xarmian/pad → github.com/PerpetualSoftware/pad
- All Go imports updated across cmd/pad, internal/{cli,server,store,
  models,collections,items,events,metrics,webhooks} (~130 files)
- Test fixtures with the literal repo slug ("xarmian/pad" in JSON
  shapes, SSH/HTTPS git URL strings, workspace_context fixtures)
  also updated, including the secondary repo entry
  (xarmian/pad-web → PerpetualSoftware/pad-web — pad-web was also
  moved to the org per branch context)

Docs / config
- README badges, install instructions, brew tap, Docker image, source
  build path, sponsor link (sponsor link kept as personal @xarmian)
- Subtitle: "Project management for developers and AI agents." →
  "Collaborate with your AI agents." (README, manifests, web layout
  meta, .goreleaser homebrew description)
- CONTRIBUTING.md, SECURITY.md, skills/INSTALL.md
- .goreleaser.yaml: homebrew_casks owner, GHCR image, release github
  owner, cosign cert-identity regex, comments
- .github/workflows/release.yml: tap/release comments
- deploy/k8s/deployment.yaml: container image
- docs/deployment.md: clone URL
- web/static/{site.webmanifest,manifest.json}: description
- web/src/routes/+layout.svelte: meta description + og:description

Brew tap path is PerpetualSoftware/tap/pad (CamelCase, matches
GitHub user case). GHCR image is ghcr.io/perpetualsoftware/pad
(lowercased per GHCR's URL normalization). CODEOWNERS @xarmian and
FUNDING.yml github: xarmian intentionally retained — those are the
personal maintainer / sponsor account, separate from the org repo.

Verification: go build ./..., go test ./... (all pkgs pass), web
build, and make install all clean (TASK-844, TASK-845).
2026-04-28 12:26:39 -04:00

118 lines
3.5 KiB
Go

package items
import (
"testing"
"github.com/PerpetualSoftware/pad/internal/models"
)
func TestMigrateFields_MatchingTypes(t *testing.T) {
source := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"open", "done"}},
{Key: "priority", Type: "select", Options: []string{"low", "high"}},
}
target := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"open", "closed"}, Required: true},
{Key: "priority", Type: "select", Options: []string{"low", "medium", "high"}},
}
fields := map[string]any{"status": "open", "priority": "high"}
result := MigrateFields(fields, source, target)
if result.Fields["status"] != "open" {
t.Errorf("status: got %v, want 'open'", result.Fields["status"])
}
if result.Fields["priority"] != "high" {
t.Errorf("priority: got %v, want 'high'", result.Fields["priority"])
}
if len(result.Dropped) != 0 {
t.Errorf("dropped: got %v, want none", result.Dropped)
}
}
func TestMigrateFields_SelectValueNotInTarget(t *testing.T) {
source := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"open", "in-progress", "done"}},
}
target := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"todo", "doing", "done"}, Required: true, Default: "todo"},
}
fields := map[string]any{"status": "in-progress"}
result := MigrateFields(fields, source, target)
// "in-progress" is not in target options, should be dropped and default applied
if result.Fields["status"] != "todo" {
t.Errorf("status: got %v, want 'todo' (default after drop)", result.Fields["status"])
}
}
func TestMigrateFields_DropsExtraFields(t *testing.T) {
source := []models.FieldDef{
{Key: "severity", Type: "select", Options: []string{"low", "high"}},
{Key: "browser", Type: "text"},
}
target := []models.FieldDef{
{Key: "priority", Type: "select", Options: []string{"low", "high"}},
}
fields := map[string]any{"severity": "high", "browser": "Chrome"}
result := MigrateFields(fields, source, target)
if len(result.Dropped) != 2 {
t.Errorf("dropped: got %d, want 2", len(result.Dropped))
}
}
func TestMigrateFields_TypeConversion(t *testing.T) {
source := []models.FieldDef{
{Key: "count", Type: "number"},
{Key: "status", Type: "select", Options: []string{"open"}},
}
target := []models.FieldDef{
{Key: "count", Type: "text"},
{Key: "status", Type: "text"},
}
fields := map[string]any{"count": 42, "status": "open"}
result := MigrateFields(fields, source, target)
if result.Fields["count"] != "42" {
t.Errorf("count: got %v, want '42'", result.Fields["count"])
}
if result.Fields["status"] != "open" {
t.Errorf("status: got %v, want 'open'", result.Fields["status"])
}
}
func TestMigrateFields_RequiredFieldMissing(t *testing.T) {
source := []models.FieldDef{}
target := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"open"}, Required: true},
}
fields := map[string]any{}
result := MigrateFields(fields, source, target)
if len(result.Errors) != 1 {
t.Errorf("errors: got %d, want 1", len(result.Errors))
}
}
func TestMigrateFields_DefaultApplied(t *testing.T) {
source := []models.FieldDef{}
target := []models.FieldDef{
{Key: "status", Type: "select", Options: []string{"open", "done"}, Required: true, Default: "open"},
}
fields := map[string]any{}
result := MigrateFields(fields, source, target)
if result.Fields["status"] != "open" {
t.Errorf("status: got %v, want 'open'", result.Fields["status"])
}
if len(result.Errors) != 0 {
t.Errorf("errors: got %v, want none", result.Errors)
}
}