24 lines
524 B
Nim
24 lines
524 B
Nim
|
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)
|