Files
tenant-registry/internal/server/catalog_trial_test.go
T
sharang 3f4dfa0cdc
ci / shared (push) Successful in 14s
ci / test (push) Successful in 25m31s
ci / image (push) Successful in 37s
fix(trial): a product trial ends with the workspace's trial (#77)
2026-10-15 16:28:01 +00:00

31 lines
902 B
Go

package server
import (
"testing"
"time"
"git.breakpilot.com/platform/tenant-registry/internal/store"
)
func TestProductTrialEnd(t *testing.T) {
now := time.Date(2026, 10, 15, 9, 0, 0, 0, time.UTC)
later := now.Add(14 * 24 * time.Hour)
past := now.Add(-time.Hour)
def := now.Add(7 * 24 * time.Hour)
for _, c := range []struct {
name string
t *store.Tenant
want time.Time
}{
{"no tenant", nil, def},
{"trial with a later end", &store.Tenant{Status: store.StatusTrial, TrialEndsAt: &later}, later},
{"trial without an end", &store.Tenant{Status: store.StatusTrial}, def},
{"trial already over", &store.Tenant{Status: store.StatusTrial, TrialEndsAt: &past}, def},
{"paying workspace", &store.Tenant{Status: "active", TrialEndsAt: &later}, def},
} {
if got := productTrialEnd(c.t, now, 7); !got.Equal(c.want) {
t.Errorf("%s: %v, want %v", c.name, got, c.want)
}
}
}