github.com/stripe/stripe-go/v76@v76.25.0/invoice/client_test.go (about) 1 package invoice 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 TestInvoiceGet(t *testing.T) { 12 invoice, err := Get("in_123", nil) 13 assert.Nil(t, err) 14 assert.NotNil(t, invoice) 15 } 16 17 func TestInvoiceList(t *testing.T) { 18 i := List(&stripe.InvoiceListParams{}) 19 20 // Verify that we can get at least one invoice 21 assert.True(t, i.Next()) 22 assert.Nil(t, i.Err()) 23 assert.NotNil(t, i.Invoice()) 24 assert.NotNil(t, i.InvoiceList()) 25 } 26 27 func TestInvoiceListLines(t *testing.T) { 28 i := ListLines(&stripe.InvoiceListLinesParams{ 29 Invoice: stripe.String("in_123"), 30 }) 31 32 // Verify that we can get at least one invoice 33 assert.True(t, i.Next()) 34 assert.Nil(t, i.Err()) 35 assert.NotNil(t, i.InvoiceLineItem()) 36 assert.NotNil(t, i.InvoiceLineItemList()) 37 } 38 39 func TestInvoiceNew(t *testing.T) { 40 invoice, err := New(&stripe.InvoiceParams{ 41 CollectionMethod: stripe.String(string(stripe.InvoiceCollectionMethodChargeAutomatically)), 42 Customer: stripe.String("cus_123"), 43 }) 44 assert.Nil(t, err) 45 assert.NotNil(t, invoice) 46 } 47 48 func TestInvoicePay(t *testing.T) { 49 invoice, err := Pay("in_123", &stripe.InvoicePayParams{ 50 Source: stripe.String("src_123"), 51 }) 52 assert.Nil(t, err) 53 assert.NotNil(t, invoice) 54 } 55 56 func TestInvoiceUpdate(t *testing.T) { 57 invoice, err := Update("in_123", &stripe.InvoiceParams{ 58 Params: stripe.Params{ 59 Metadata: map[string]string{ 60 "foo": "bar", 61 }, 62 }, 63 }) 64 assert.Nil(t, err) 65 assert.NotNil(t, invoice) 66 } 67 68 func TestInvoiceDel(t *testing.T) { 69 invoice, err := Del("in_123", &stripe.InvoiceParams{}) 70 assert.Nil(t, err) 71 assert.NotNil(t, invoice) 72 } 73 74 func TestInvoiceFinalizeInvoice(t *testing.T) { 75 invoice, err := FinalizeInvoice("in_123", &stripe.InvoiceFinalizeInvoiceParams{}) 76 assert.Nil(t, err) 77 assert.NotNil(t, invoice) 78 } 79 80 func TestInvoiceMarkUncollectible(t *testing.T) { 81 invoice, err := MarkUncollectible("in_123", &stripe.InvoiceMarkUncollectibleParams{}) 82 assert.Nil(t, err) 83 assert.NotNil(t, invoice) 84 } 85 86 func TestInvoiceSendInvoice(t *testing.T) { 87 invoice, err := SendInvoice("in_123", &stripe.InvoiceSendInvoiceParams{}) 88 assert.Nil(t, err) 89 assert.NotNil(t, invoice) 90 } 91 92 func TestInvoiceVoidInvoice(t *testing.T) { 93 invoice, err := VoidInvoice("in_123", &stripe.InvoiceVoidInvoiceParams{}) 94 assert.Nil(t, err) 95 assert.NotNil(t, invoice) 96 }