jsoniter_reader_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package jsoniter
  2. import (
  3. "github.com/stretchr/testify/require"
  4. "strings"
  5. "testing"
  6. "time"
  7. )
  8. func Test_reader_and_load_more(t *testing.T) {
  9. should := require.New(t)
  10. type TestObject struct {
  11. CreatedAt time.Time
  12. }
  13. reader := strings.NewReader(`
  14. {
  15. "agency": null,
  16. "candidateId": 0,
  17. "candidate": "Blah Blah",
  18. "bookingId": 0,
  19. "shiftId": 1,
  20. "shiftTypeId": 0,
  21. "shift": "Standard",
  22. "bonus": 0,
  23. "bonusNI": 0,
  24. "days": [],
  25. "totalHours": 27,
  26. "expenses": [],
  27. "weekEndingDateSystem": "2016-10-09",
  28. "weekEndingDateClient": "2016-10-09",
  29. "submittedAt": null,
  30. "submittedById": null,
  31. "approvedAt": "2016-10-10T18:38:04Z",
  32. "approvedById": 0,
  33. "authorisedAt": "2016-10-10T18:38:04Z",
  34. "authorisedById": 0,
  35. "invoicedAt": "2016-10-10T20:00:00Z",
  36. "revokedAt": null,
  37. "revokedById": null,
  38. "revokeReason": null,
  39. "rejectedAt": null,
  40. "rejectedById": null,
  41. "rejectReasonCode": null,
  42. "rejectReason": null,
  43. "createdAt": "2016-10-03T00:00:00Z",
  44. "updatedAt": "2016-11-09T10:26:13Z",
  45. "updatedById": null,
  46. "overrides": [],
  47. "bookingApproverId": null,
  48. "bookingApprover": null,
  49. "status": "approved"
  50. }
  51. `)
  52. decoder := ConfigCompatibleWithStandardLibrary.NewDecoder(reader)
  53. obj := TestObject{}
  54. should.Nil(decoder.Decode(&obj))
  55. }