33 lines
702 B
Go
33 lines
702 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestTierForPriceID(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cfg := &Config{
|
|
StripePriceIDPremium: "price_premium_123",
|
|
StripePriceIDPro: "price_pro_456",
|
|
StripePriceIDPremiumAnnual: "price_premium_yr",
|
|
StripePriceIDProAnnual: "price_pro_yr",
|
|
}
|
|
|
|
tests := []struct {
|
|
priceID string
|
|
want string
|
|
}{
|
|
{"price_premium_123", "premium"},
|
|
{"price_pro_456", "pro"},
|
|
{"price_premium_yr", "premium"},
|
|
{"price_pro_yr", "pro"},
|
|
{"price_unknown", ""},
|
|
{"", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
if got := cfg.TierForPriceID(tt.priceID); got != tt.want {
|
|
t.Errorf("TierForPriceID(%q) = %q, want %q", tt.priceID, got, tt.want)
|
|
}
|
|
}
|
|
}
|