Skip to content

Commit

Permalink
Add Charge application tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetrovics-stripe committed Nov 3, 2016
1 parent b897ada commit 57f5c33
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions application_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package stripe

import (
"encoding/json"
"testing"
)

func TestApplicationUnmarshal(t *testing.T) {
applicationData := map[string]interface{}{
"id": "ca_1234",
"name": "My Application Name",
}

bytes, err := json.Marshal(&applicationData)
if err != nil {
t.Error(err)
}

var application Application
err = json.Unmarshal(bytes, &application)
if err != nil {
t.Error(err)
}

if application.ID != "ca_1234" {
t.Errorf("Problem deserializing application, got ID %v", application.ID)
}

if application.Name != "My Application Name" {
t.Errorf("Problem deserializing application, got name %v", application.Name)
}
}
5 changes: 5 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func ExampleCharge_get() {

params := &stripe.ChargeParams{}
params.Expand("customer")
params.Expand("application")
params.Expand("balance_transaction")

ch, err := charge.Get("ch_example_id", params)
Expand All @@ -48,6 +49,10 @@ func ExampleCharge_get() {
log.Fatal(err)
}

if ch.Application != nil {
log.Fatal(err)
}

log.Printf("%v\n", ch.ID)
}

Expand Down

0 comments on commit 57f5c33

Please sign in to comment.