diff --git a/application_test.go b/application_test.go new file mode 100644 index 0000000000..604b361743 --- /dev/null +++ b/application_test.go @@ -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) + } +} diff --git a/example_test.go b/example_test.go index 6e445a214b..b0ac6c3bbc 100644 --- a/example_test.go +++ b/example_test.go @@ -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) @@ -48,6 +49,10 @@ func ExampleCharge_get() { log.Fatal(err) } + if ch.Application != nil { + log.Fatal(err) + } + log.Printf("%v\n", ch.ID) }