-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add usage data for stripe client usage (#1982)
* Add some client tests * Add usageBackend * Move UsageBackend to stripe package * Update usage string to stripe_client
- Loading branch information
1 parent
fb9b421
commit 2917c4b
Showing
7 changed files
with
88 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
package account | ||
package account_test | ||
|
||
import ( | ||
"testing" | ||
|
||
assert "github.com/stretchr/testify/require" | ||
stripe "github.com/stripe/stripe-go/v81" | ||
_ "github.com/stripe/stripe-go/v81/testing" | ||
"github.com/stripe/stripe-go/v81/client" | ||
. "github.com/stripe/stripe-go/v81/testing" | ||
) | ||
|
||
func TestAccountDel(t *testing.T) { | ||
account, err := Del("acct_123", nil) | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.Del("acct_123", nil) | ||
assert.Nil(t, err) | ||
assert.NotNil(t, account) | ||
} | ||
|
||
func TestAccountGet(t *testing.T) { | ||
account, err := Get() | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.Get() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, account) | ||
} | ||
|
||
func TestAccountGetByID(t *testing.T) { | ||
account, err := GetByID("acct_123", nil) | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.GetByID("acct_123", nil) | ||
assert.Nil(t, err) | ||
assert.NotNil(t, account) | ||
} | ||
|
||
func TestAccountList(t *testing.T) { | ||
i := List(&stripe.AccountListParams{}) | ||
sc := client.New(TestAPIKey, nil) | ||
i := sc.Accounts.List(&stripe.AccountListParams{}) | ||
|
||
// Verify that we can get at least one account | ||
assert.True(t, i.Next()) | ||
|
@@ -37,7 +42,8 @@ func TestAccountList(t *testing.T) { | |
} | ||
|
||
func TestAccountNew(t *testing.T) { | ||
account, err := New(&stripe.AccountParams{ | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.New(&stripe.AccountParams{ | ||
BusinessProfile: &stripe.AccountBusinessProfileParams{ | ||
Name: stripe.String("name"), | ||
SupportEmail: stripe.String("[email protected]"), | ||
|
@@ -103,15 +109,17 @@ func TestAccountNew(t *testing.T) { | |
} | ||
|
||
func TestAccountReject(t *testing.T) { | ||
account, err := Reject("acct_123", &stripe.AccountRejectParams{ | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.Reject("acct_123", &stripe.AccountRejectParams{ | ||
Reason: stripe.String("fraud"), | ||
}) | ||
assert.Nil(t, err) | ||
assert.NotNil(t, account) | ||
} | ||
|
||
func TestAccountUpdate(t *testing.T) { | ||
account, err := Update("acct_123", &stripe.AccountParams{ | ||
sc := client.New(TestAPIKey, nil) | ||
account, err := sc.Accounts.Update("acct_123", &stripe.AccountParams{ | ||
Company: &stripe.AccountCompanyParams{ | ||
Address: &stripe.AddressParams{ | ||
Country: stripe.String("CA"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters