-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplans_extra_test.go
More file actions
168 lines (154 loc) · 5.35 KB
/
Copy pathplans_extra_test.go
File metadata and controls
168 lines (154 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package plans_test
import (
"testing"
"instant.dev/common/plans"
)
// These tests cover the limit-accessor methods that were previously 0% in the
// coverage report. They run against the registry returned by plans.Default().
func TestStorageLimitMB(t *testing.T) {
r := plans.Default()
// anonymous: postgres = 10MB, vector mirrors postgres
if got := r.StorageLimitMB("anonymous", "postgres"); got != 10 {
t.Errorf("anonymous postgres = %d, want 10", got)
}
if got := r.StorageLimitMB("anonymous", "vector"); got != 10 {
t.Errorf("anonymous vector = %d, want 10", got)
}
if got := r.StorageLimitMB("anonymous", "redis"); got != 5 {
t.Errorf("anonymous redis = %d, want 5", got)
}
if got := r.StorageLimitMB("anonymous", "mongodb"); got != 5 {
t.Errorf("anonymous mongodb = %d, want 5", got)
}
// Unknown service returns -1.
if got := r.StorageLimitMB("anonymous", "made-up"); got != -1 {
t.Errorf("unknown service = %d, want -1", got)
}
// Other services pull from the right field (sanity, no exact-value coupling).
_ = r.StorageLimitMB("hobby", "queue")
_ = r.StorageLimitMB("hobby", "storage")
_ = r.StorageLimitMB("hobby", "webhook")
}
func TestConnectionsLimit(t *testing.T) {
r := plans.Default()
if got := r.ConnectionsLimit("anonymous", "postgres"); got != 2 {
t.Errorf("anonymous postgres conns = %d, want 2", got)
}
if got := r.ConnectionsLimit("anonymous", "vector"); got != 2 {
t.Errorf("anonymous vector conns = %d, want 2", got)
}
if got := r.ConnectionsLimit("anonymous", "mongodb"); got != 2 {
t.Errorf("anonymous mongodb conns = %d, want 2", got)
}
// Unknown service => -1
if got := r.ConnectionsLimit("anonymous", "redis"); got != -1 {
t.Errorf("redis conns = %d, want -1", got)
}
}
func TestTeamMemberLimit_DefaultsByTier(t *testing.T) {
r := plans.Default()
// strict-80% margin redesign (2026-06-05): team.team_members is now a
// finite 25 (was -1 unlimited). The YAML value takes precedence over the
// built-in fallback in TeamMemberLimit.
if got := r.TeamMemberLimit("team"); got != 25 {
t.Errorf("team = %d, want 25", got)
}
// pro fallback default = 5 unless overridden in YAML (it may also be set
// explicitly; both are acceptable provided it's > 1).
if got := r.TeamMemberLimit("pro"); got <= 1 {
t.Errorf("pro team limit must be > 1, got %d", got)
}
// anonymous => 1
if got := r.TeamMemberLimit("anonymous"); got != 1 {
t.Errorf("anonymous = %d, want 1", got)
}
// growth has its own branch; just probe the function works
_ = r.TeamMemberLimit("growth")
}
func TestThroughputLimit(t *testing.T) {
r := plans.Default()
if got := r.ThroughputLimit("anonymous", "redis"); got != 1000 {
t.Errorf("anonymous redis = %d, want 1000", got)
}
if got := r.ThroughputLimit("anonymous", "mongodb"); got != 100 {
t.Errorf("anonymous mongodb = %d, want 100", got)
}
if got := r.ThroughputLimit("anonymous", "unknown"); got != -1 {
t.Errorf("unknown = %d, want -1", got)
}
}
func TestCustomDomainsAllowed(t *testing.T) {
r := plans.Default()
// anonymous => false; pro/team should generally be true (config-dependent)
if r.CustomDomainsAllowed("anonymous") {
t.Error("anonymous should not allow custom domains")
}
_ = r.CustomDomainsAllowed("pro")
_ = r.CustomDomainsMaxLimit("anonymous")
_ = r.CustomDomainsMaxLimit("pro")
}
func TestVaultAndDeployLimits(t *testing.T) {
r := plans.Default()
_ = r.VaultMaxEntries("anonymous")
_ = r.VaultMaxEntries("pro")
if envs := r.VaultEnvsAllowed("pro"); envs == nil {
t.Error("VaultEnvsAllowed should return non-nil slice")
}
_ = r.DeploymentsAppsLimit("hobby")
_ = r.DeploymentsAppsLimit("anonymous")
}
func TestQueueCountLimit(t *testing.T) {
r := plans.Default()
// All tiers should resolve without panicking; result may be -1 or finite.
_ = r.QueueCountLimit("anonymous")
_ = r.QueueCountLimit("hobby")
_ = r.QueueCountLimit("pro")
}
func TestBackupAccessors(t *testing.T) {
r := plans.Default()
// anonymous: backups disabled.
if got := r.BackupRetentionDays("anonymous"); got != 0 {
t.Errorf("anonymous retention = %d, want 0", got)
}
if r.BackupRestoreEnabled("anonymous") {
t.Error("anonymous should not allow restore")
}
if got := r.ManualBackupsPerDay("anonymous"); got != 0 {
t.Errorf("anonymous manual = %d, want 0", got)
}
// pro/team should generally allow restore.
_ = r.BackupRestoreEnabled("pro")
_ = r.ManualBackupsPerDay("pro")
_ = r.BackupRetentionDays("team")
_ = r.RPOMinutes("pro")
_ = r.RTOMinutes("pro")
}
func TestPromotions_NoCrash(t *testing.T) {
r := plans.Default()
// Default config may have no promotions; either way the slice is non-nil
// shape and the method doesn't panic.
_ = r.Promotions()
}
func TestPriceMonthly_DisplayName_IsDedicated(t *testing.T) {
r := plans.Default()
if r.DisplayName("anonymous") == "" {
t.Error("DisplayName empty")
}
if r.PriceMonthly("anonymous") != 0 {
t.Errorf("anonymous price = %d, want 0", r.PriceMonthly("anonymous"))
}
_ = r.IsDedicatedTier("growth")
_ = r.BillingPeriod("pro_yearly")
_ = r.BillingPeriod("pro")
}
func TestCanonicalTier_YearlySuffix(t *testing.T) {
if plans.CanonicalTier("pro_yearly") != "pro" {
t.Errorf("pro_yearly should canonicalize to pro")
}
if plans.CanonicalTier("pro") != "pro" {
t.Errorf("pro should round-trip to pro")
}
if plans.CanonicalTier("hobby_plus_yearly") != "hobby_plus" {
t.Errorf("hobby_plus_yearly should canonicalize to hobby_plus")
}
}