Skip to content

Commit 687998f

Browse files
committed
test(config): cover PAYMENT_TEST_MODE_ENABLED parse + add RAZORPAY_TEST_* to allKeys
allKeys() (env host-state clearer) was missing the RAZORPAY_TEST_* vars and the new PAYMENT_TEST_MODE_ENABLED flag, so a leaked host env could bleed into config tests. Add them + a TestLoad_PaymentTestModeEnabled mirroring the other *_ENABLED flag tests (100%-patch coverage for the new parse branch). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6a17b5c commit 687998f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

internal/config/config_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ func allKeys() []string {
4040
"RAZORPAY_PLAN_ID_TEAM", "RAZORPAY_PLAN_ID_HOBBY_ANNUAL",
4141
"RAZORPAY_PLAN_ID_HOBBY_PLUS_ANNUAL", "RAZORPAY_PLAN_ID_PRO_ANNUAL",
4242
"RAZORPAY_PLAN_ID_GROWTH_ANNUAL", "RAZORPAY_PLAN_ID_TEAM_ANNUAL",
43+
"RAZORPAY_TEST_KEY_ID", "RAZORPAY_TEST_KEY_SECRET", "RAZORPAY_TEST_WEBHOOK_SECRET",
44+
"RAZORPAY_TEST_PLAN_ID_HOBBY", "RAZORPAY_TEST_PLAN_ID_HOBBY_PLUS",
45+
"RAZORPAY_TEST_PLAN_ID_PRO", "PAYMENT_TEST_MODE_ENABLED",
4346
"RESEND_API_KEY", "EMAIL_PROVIDER", "BREVO_API_KEY",
4447
"EMAIL_FROM_NAME", "EMAIL_FROM_ADDRESS",
4548
"GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET",
@@ -419,6 +422,21 @@ func TestLoad_ResourceCountCapsEnabled(t *testing.T) {
419422
}
420423
}
421424

425+
func TestLoad_PaymentTestModeEnabled(t *testing.T) {
426+
for _, val := range []string{"true", "1", "yes", "TRUE", " Yes "} {
427+
applyBaselineEnv(t, map[string]string{"PAYMENT_TEST_MODE_ENABLED": val})
428+
if !Load().PaymentTestModeEnabled {
429+
t.Errorf("PAYMENT_TEST_MODE_ENABLED=%q should enable", val)
430+
}
431+
}
432+
for _, val := range []string{"false", "0", "no", "maybe", ""} {
433+
applyBaselineEnv(t, map[string]string{"PAYMENT_TEST_MODE_ENABLED": val})
434+
if Load().PaymentTestModeEnabled {
435+
t.Errorf("PAYMENT_TEST_MODE_ENABLED=%q should stay disabled (default OFF / fail-closed)", val)
436+
}
437+
}
438+
}
439+
422440
func TestLoad_GitHubAppEnabled(t *testing.T) {
423441
// When enabling the App, Load() fails closed unless the webhook secret +
424442
// private key + app id are present (review HIGH-1), so set them here.

0 commit comments

Comments
 (0)