Files
descrybe/apps/api/internal/billing/public_plans_test.go
T
greeneclipse 8580c996c3 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.
2026-08-09 22:47:43 +02:00

53 lines
1.2 KiB
Go

package billing
import (
"strings"
"testing"
)
func TestIsPublicProductPlan(t *testing.T) {
public := []string{"Free", "Starter", "Growth", "Business", "Enterprise", " free ", "GROWTH"}
for _, name := range public {
if !IsPublicProductPlan(name) {
t.Fatalf("expected public: %q", name)
}
}
hidden := []string{"A1", "Merkur trial", "Merkur", "Meur", "Basic", "Professional", "Mini", ""}
for _, name := range hidden {
if IsPublicProductPlan(name) {
t.Fatalf("expected hidden from public pricing: %q", name)
}
}
}
func TestFilterPublicPlans(t *testing.T) {
all := []Plan{
{Name: "Basic"},
{Name: "A1", IsCustom: true},
{Name: "Merkur trial", IsCustom: true},
{Name: "Free"},
{Name: "Starter"},
{Name: "Growth"},
{Name: "Business"},
{Name: "Enterprise", IsCustom: true},
{Name: "Professional"},
}
out := make([]Plan, 0, 5)
for _, p := range all {
if IsPublicProductPlan(p.Name) {
out = append(out, p)
}
}
if len(out) != 5 {
t.Fatalf("got %d public plans, want 5: %+v", len(out), out)
}
for _, p := range out {
key := strings.ToLower(p.Name)
switch key {
case "free", "starter", "growth", "business", "enterprise":
default:
t.Fatalf("unexpected public plan %q", p.Name)
}
}
}