Skip to content

Instantly share code, notes, and snippets.

@csmith0651
Last active October 18, 2016 12:58
Show Gist options
  • Save csmith0651/d2f665a81df36086e15bfdbf229f1369 to your computer and use it in GitHub Desktop.
Save csmith0651/d2f665a81df36086e15bfdbf229f1369 to your computer and use it in GitHub Desktop.
person_test
package person_test
import (
. "github.com/tapjoy/mocks3fetcher/person"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("person", func() {
goodJson := `
[
{
"Age": 100,
"First": "Craig",
"Last": "Smith"
},
{
"Age": 2,
"First": "Eric",
"Last": "Smith"
}
]
`
Context("ExtractPersonData", func() {
badJson := []byte("bad json data")
It("malformed JSON generates an error", func() {
_, err := ExtractPersonData(badJson)
Expect(err).To(HaveOccurred())
})
It("properly formed JSON returns array of Person", func() {
data, err := ExtractPersonData([]byte(goodJson))
Expect(err).ToNot(HaveOccurred())
Expect(data).To(HaveLen(2))
Expect(data[1].Last).To(Equal("Smith"))
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment