github.com/stripe/stripe-go/v76@v76.25.0/plan/client_test.go (about) 1 package plan 2 3 import ( 4 "testing" 5 6 assert "github.com/stretchr/testify/require" 7 stripe "github.com/stripe/stripe-go/v76" 8 _ "github.com/stripe/stripe-go/v76/testing" 9 ) 10 11 func TestPlanDel(t *testing.T) { 12 plan, err := Del("gold", nil) 13 assert.Nil(t, err) 14 assert.NotNil(t, plan) 15 } 16 17 func TestPlanGet(t *testing.T) { 18 plan, err := Get("gold", nil) 19 assert.Nil(t, err) 20 assert.NotNil(t, plan) 21 } 22 23 func TestPlanList(t *testing.T) { 24 i := List(&stripe.PlanListParams{}) 25 26 // Verify that we can get at least one plan 27 assert.True(t, i.Next()) 28 assert.Nil(t, i.Err()) 29 assert.NotNil(t, i.Plan()) 30 assert.NotNil(t, i.PlanList()) 31 } 32 33 func TestPlanNew(t *testing.T) { 34 plan, err := New(&stripe.PlanParams{ 35 AmountDecimal: stripe.Float64(0.0123456789), 36 BillingScheme: stripe.String(string(stripe.PlanBillingSchemeTiered)), 37 Currency: stripe.String(string(stripe.CurrencyUSD)), 38 ID: stripe.String("sapphire-elite"), 39 Interval: stripe.String(string(stripe.PlanIntervalMonth)), 40 Product: &stripe.PlanProductParams{ 41 ID: stripe.String("plan_id"), 42 Name: stripe.String("Sapphire Elite"), 43 StatementDescriptor: stripe.String("statement descriptor"), 44 }, 45 Tiers: []*stripe.PlanTierParams{ 46 {UnitAmount: stripe.Int64(500), UpTo: stripe.Int64(5)}, 47 {UnitAmount: stripe.Int64(400), UpTo: stripe.Int64(10)}, 48 {UnitAmount: stripe.Int64(300), UpTo: stripe.Int64(15)}, 49 {UnitAmount: stripe.Int64(200), UpTo: stripe.Int64(20)}, 50 {UnitAmount: stripe.Int64(200), UpToInf: stripe.Bool(true)}, 51 }, 52 }) 53 assert.Nil(t, err) 54 assert.NotNil(t, plan) 55 } 56 57 func TestPlanUpdate(t *testing.T) { 58 plan, err := Update("gold", &stripe.PlanParams{ 59 Nickname: stripe.String("Updated nickame"), 60 }) 61 assert.Nil(t, err) 62 assert.NotNil(t, plan) 63 }