Initial commit of Descrybe v2 without local scratch artifacts.

Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
2026-08-09 22:47:43 +02:00
commit 8580c996c3
1285 changed files with 325780 additions and 0 deletions
@@ -0,0 +1,75 @@
package main
import (
"context"
"strings"
"testing"
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
)
func TestDecideAssignMissingPlanSkipsA1(t *testing.T) {
t.Parallel()
mutate, reason := decideAssignMissingPlan(true, billing.A1LegacyCompanyID, "Anything")
if mutate || reason != "a1_cohort" {
t.Fatalf("A1 legacy id must never assign (even with -confirm): mutate=%v reason=%q", mutate, reason)
}
mutate, reason = decideAssignMissingPlan(true, "other-legacy-id", "A1 Slovenija")
if !mutate || reason != "" {
t.Fatalf("display name alone must not skip assign: mutate=%v reason=%q", mutate, reason)
}
mutate, reason = decideAssignMissingPlan(false, billing.A1LegacyCompanyID, "A1")
if mutate || reason != "" {
t.Fatalf("list-only: mutate=%v reason=%q", mutate, reason)
}
}
func TestResolveFallbackPlanIDEmpty(t *testing.T) {
t.Parallel()
id, err := resolveFallbackPlanID(context.Background(), nil, " ")
if err != nil {
t.Fatal(err)
}
if id != 0 {
t.Fatalf("got %d, want 0", id)
}
}
func TestNormalizeAssignPlanName(t *testing.T) {
t.Parallel()
got, err := normalizeAssignPlanName(" Free ", true)
if err != nil {
t.Fatal(err)
}
if got != "Free" {
t.Fatalf("got %q", got)
}
_, err = normalizeAssignPlanName(" ", true)
if err == nil || !strings.Contains(err.Error(), "-plan-name") {
t.Fatalf("expected plan-name error, got %v", err)
}
got, err = normalizeAssignPlanName(" ", false)
if err != nil {
t.Fatal(err)
}
if got != "" {
t.Fatalf("list-only allows empty plan name, got %q", got)
}
}
func TestGuardLiveAssign(t *testing.T) {
t.Parallel()
if err := guardLiveAssign(false, false, false); err != nil {
t.Fatalf("list-only: %v", err)
}
if err := guardLiveAssign(true, true, false); err != nil {
t.Fatalf("dry-run: %v", err)
}
if err := guardLiveAssign(true, false, true); err != nil {
t.Fatalf("confirm: %v", err)
}
err := guardLiveAssign(true, false, false)
if err == nil || !strings.Contains(err.Error(), "no blind live writes") {
t.Fatalf("expected blind-assign refusal, got %v", err)
}
}