github.com/stripe/stripe-go/v76@v76.25.0/product/client_test.go (about)

     1  package product
     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 TestProductDel(t *testing.T) {
    12  	product, err := Del("prod_123", nil)
    13  	assert.Nil(t, err)
    14  	assert.NotNil(t, product)
    15  }
    16  
    17  func TestProductGet(t *testing.T) {
    18  	product, err := Get("prod_123", nil)
    19  	assert.Nil(t, err)
    20  	assert.NotNil(t, product)
    21  }
    22  
    23  func TestProductList(t *testing.T) {
    24  	i := List(&stripe.ProductListParams{})
    25  
    26  	// Verify that we can get at least one product
    27  	assert.True(t, i.Next())
    28  	assert.Nil(t, i.Err())
    29  	assert.NotNil(t, i.Product())
    30  	assert.NotNil(t, i.ProductList())
    31  }
    32  
    33  func TestProductNew(t *testing.T) {
    34  	product, err := New(&stripe.ProductParams{
    35  		Active:      stripe.Bool(true),
    36  		Name:        stripe.String("Test Name"),
    37  		Description: stripe.String("This is a description"),
    38  		URL:         stripe.String("http://example.com"),
    39  		Shippable:   stripe.Bool(true),
    40  		PackageDimensions: &stripe.ProductPackageDimensionsParams{
    41  			Height: stripe.Float64(2.234),
    42  			Length: stripe.Float64(5.10),
    43  			Width:  stripe.Float64(6.50),
    44  			Weight: stripe.Float64(10),
    45  		},
    46  	})
    47  	assert.Nil(t, err)
    48  	assert.NotNil(t, product)
    49  }
    50  
    51  func TestProductUpdate(t *testing.T) {
    52  	product, err := Update("prod_123", &stripe.ProductParams{
    53  		Name: stripe.String("Updated Name"),
    54  	})
    55  	assert.Nil(t, err)
    56  	assert.NotNil(t, product)
    57  }