github.com/stripe/stripe-go/v76@v76.25.0/card/client_test.go (about) 1 package card 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 TestCardDel(t *testing.T) { 12 card, err := Del("card_123", &stripe.CardParams{ 13 Customer: stripe.String("cus_123"), 14 }) 15 assert.Nil(t, err) 16 assert.NotNil(t, card) 17 } 18 19 func TestCardDel_RequiresParams(t *testing.T) { 20 _, err := Del("card_123", nil) 21 assert.Error(t, err, "params should not be nil") 22 } 23 24 func TestCardGet(t *testing.T) { 25 card, err := Get("card_123", &stripe.CardParams{ 26 Customer: stripe.String("cus_123"), 27 }) 28 assert.Nil(t, err) 29 assert.NotNil(t, card) 30 } 31 32 func TestCardGet_RequiresParams(t *testing.T) { 33 _, err := Get("card_123", nil) 34 assert.Error(t, err, "params should not be nil") 35 } 36 37 func TestCardList_ByCustomer(t *testing.T) { 38 i := List(&stripe.CardListParams{Customer: stripe.String("cus_123")}) 39 40 // Verify that we can get at least one card 41 assert.True(t, i.Next()) 42 assert.Nil(t, i.Err()) 43 assert.NotNil(t, i.Card()) 44 assert.NotNil(t, i.CardList()) 45 } 46 47 func TestCardList_RequiresParams(t *testing.T) { 48 i := List(nil) 49 assert.False(t, i.Next()) 50 assert.Error(t, i.Err(), "params should not be nil") 51 } 52 53 func TestCardNew(t *testing.T) { 54 card, err := New(&stripe.CardParams{ 55 Customer: stripe.String("cus_123"), 56 Token: stripe.String("tok_123"), 57 }) 58 assert.Nil(t, err) 59 assert.NotNil(t, card) 60 } 61 62 func TestCardNew_RequiresParams(t *testing.T) { 63 _, err := New(nil) 64 assert.Error(t, err, "params should not be nil") 65 } 66 67 func TestCardUpdate(t *testing.T) { 68 card, err := Update("card_123", &stripe.CardParams{ 69 Customer: stripe.String("cus_123"), 70 Name: stripe.String("New Name"), 71 }) 72 assert.Nil(t, err) 73 assert.NotNil(t, card) 74 } 75 76 func TestCardUpdate_RequiresParams(t *testing.T) { 77 _, err := Update("card_123", nil) 78 assert.Error(t, err, "params should not be nil") 79 }