Пример #1
0
			nullPosts = []SqlNullPost{}
		})

		It("correctly unmarshal String, Int64 and Float64", func() {
			err := UnmarshalFromJSON([]byte(`
				{
					"data": {
						"id": "theID",
						"type": "sqlNullPosts",
						"attributes": {
							"title": "Test",
							"likes": 666,
							"rating": 66.66,
							"isCool": true
						}
					}
				}
			`), &nullPosts)
			Expect(err).ToNot(HaveOccurred())
			Expect(nullPosts).To(HaveLen(1))
			Expect(nullPosts[0]).To(Equal(SqlNullPost{
				ID:     "theID",
				Title:  zero.StringFrom("Test"),
				Likes:  zero.IntFrom(666),
				Rating: zero.FloatFrom(66.66),
				IsCool: zero.BoolFrom(true),
			}))
		})
	})
})
Пример #2
0
					"attributes": {
						"title": "Test",
						"likes": 666,
						"rating": 66.66,
						"isCool": true,
						"today": "%v"
					}
				}
			}
			`, timeZero.Format(time.RFC3339))), &nullPost)
			Expect(err).ToNot(HaveOccurred())
			Expect(nullPost).To(Equal(SQLNullPost{
				ID:     "theID",
				Title:  zero.StringFrom("Test"),
				Likes:  zero.IntFrom(666),
				Rating: zero.FloatFrom(66.66),
				IsCool: zero.BoolFrom(true),
				Today:  zero.TimeFrom(timeZero.UTC()),
			}))
		})

		It("correctly unmarshals Null String, Int64, Float64 and Time", func() {
			err := Unmarshal([]byte(`
			{
				"data": {
					"id": "theID",
					"type": "sqlNullPosts",
					"attributes": {
						"title": null,
						"likes": null,
						"rating": null,