Files
pad/internal/models/workspace_settings_test.go
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

103 lines
3.7 KiB
Go

package models
import "testing"
func TestParseWorkspaceSettingsEmpty(t *testing.T) {
settings, err := ParseWorkspaceSettings("")
if err != nil {
t.Fatalf("ParseWorkspaceSettings error: %v", err)
}
if settings == nil {
t.Fatal("expected settings struct")
}
if settings.Context != nil {
t.Fatalf("expected nil context for empty settings, got %#v", settings.Context)
}
}
func TestParseWorkspaceSettingsExtractsStructuredContext(t *testing.T) {
settings, err := ParseWorkspaceSettings(`{"context":{"repositories":[{"name":"docapp","role":"primary","path":".","repo":"PerpetualSoftware/pad"}],"paths":{"docs_repo":"../pad-web"},"commands":{"build":"make install","test":"go test ./..."},"stack":{"languages":["go","typescript"],"frameworks":["sveltekit"],"package_managers":["npm"]},"deployment":{"mode":"remote","base_url":"http://127.0.0.1:7777"},"assumptions":["pad-web lives at ../pad-web"]}}`)
if err != nil {
t.Fatalf("ParseWorkspaceSettings error: %v", err)
}
if settings.Context == nil {
t.Fatal("expected context")
}
if len(settings.Context.Repositories) != 1 {
t.Fatalf("expected 1 repository, got %#v", settings.Context.Repositories)
}
if settings.Context.Paths == nil || settings.Context.Paths.DocsRepo != "../pad-web" {
t.Fatalf("expected docs repo path, got %#v", settings.Context.Paths)
}
if settings.Context.Commands == nil || settings.Context.Commands.Test != "go test ./..." {
t.Fatalf("expected test command, got %#v", settings.Context.Commands)
}
if settings.Context.Stack == nil || len(settings.Context.Stack.Languages) != 2 {
t.Fatalf("expected stack languages, got %#v", settings.Context.Stack)
}
if settings.Context.Deployment == nil || settings.Context.Deployment.Mode != "remote" {
t.Fatalf("expected deployment mode remote, got %#v", settings.Context.Deployment)
}
}
func TestSerializeWorkspaceSettingsRoundTrip(t *testing.T) {
raw, err := SerializeWorkspaceSettings(&WorkspaceSettings{
Context: &WorkspaceContext{
Commands: &WorkspaceCommands{
Build: "make install",
Test: "go test ./...",
},
Assumptions: []string{"Tasks should be PR-sized"},
},
})
if err != nil {
t.Fatalf("SerializeWorkspaceSettings error: %v", err)
}
context := ExtractWorkspaceContext(raw)
if context == nil {
t.Fatal("expected extracted context")
}
if context.Commands == nil || context.Commands.Build != "make install" {
t.Fatalf("expected build command to survive round trip, got %#v", context.Commands)
}
if len(context.Assumptions) != 1 {
t.Fatalf("expected assumptions to survive round trip, got %#v", context.Assumptions)
}
}
func TestApplyWorkspaceContextPreservesUnknownSettings(t *testing.T) {
raw, err := ApplyWorkspaceContext(`{"theme":"dark","context":{"assumptions":["old"]}}`, &WorkspaceContext{
Assumptions: []string{"new"},
Commands: &WorkspaceCommands{Build: "make install"},
})
if err != nil {
t.Fatalf("ApplyWorkspaceContext error: %v", err)
}
settingsMap, err := parseWorkspaceSettingsMap(raw)
if err != nil {
t.Fatalf("parseWorkspaceSettingsMap error: %v", err)
}
if settingsMap["theme"] != "dark" {
t.Fatalf("expected unknown settings to be preserved, got %#v", settingsMap)
}
context := ExtractWorkspaceContext(raw)
if context == nil || context.Commands == nil || context.Commands.Build != "make install" {
t.Fatalf("expected context update to apply, got %#v", context)
}
}
func TestNormalizeWorkspaceSettingsRejectsInvalidJSON(t *testing.T) {
if _, err := NormalizeWorkspaceSettings(`{"context":`); err == nil {
t.Fatal("expected invalid JSON to fail normalization")
}
}
func TestExtractWorkspaceContextIgnoresInvalidSettings(t *testing.T) {
if got := ExtractWorkspaceContext(`{"context":`); got != nil {
t.Fatalf("expected invalid settings to return nil context, got %#v", got)
}
}