buffoonery/test/tjsonutils.nim

24 lines
524 B
Nim
Raw Normal View History

2022-01-22 18:50:29 -06:00
import json, times, unittest, uuids
import buffoonery/jsonutils
suite "jsonutils":
let n = %*{
"numVal": 12345,
"strVal": "Test string",
"uuid": $genUUID(),
"isoDate": "2021-07-19T16:20:32+00:00",
"month": "2021-07"
}
test "getOrFail":
check:
n.getOrFail("strVal").getStr == "Test string"
n.getOrFail("numVal").getInt == 12345
expect(ValueError):
discard n.getOrFail("missingVal")
test "parseMonth":
check n.parseMonth("month") == "2021-07".parse(MONTH_FORMAT)