Show HN: Go-testdeep, testing JSON content in Golang

# · ✸ 14 · 💬 0 · one year ago · go-testdeep.zetta.rocks · zeptomax · 📷
JSON operator allows to compare the JSON representation of data against expectedJSON. expectedJSON can be a:. expectedJSON JSON value can contain placeholders. JSON does its best to convert back the JSON corresponding to a placeholder to the type of the placeholder or, if the placeholder is an operator, to the type behind the operator. Println("Check nil got is null:", ok) // Output: // check got with age then fullname: true // check got with fullname then age: true // check got with nicely formatted and commented JSON: true // check got with gender field: false // check got with fullname only: false // check boolean got is true: true // check numeric got is 42: true // check nil got is null: true. Println("Check got w/num & named placeholders:", ok) // Output: // check got with numeric placeholders without operators: true // check got with numeric placeholders: true // check got with double-quoted numeric placeholders: true // check got with named placeholders: true // check got w/named placeholders, and children w/go structs: true // check got w/num & named placeholders: true. Println("Check got with complex operators, w/placeholder args:", ok) // Output: // check got with simple operators: true // check got with operator shortcuts: true // check got with complex operators: true // check got with complex operators: false // check got with complex operators, w/placeholder args: true. Println("Raw strings:", ok) // Output: // Original: true // JSON compliant: true // JSON multilines strings: true // Raw strings: true. Println("Check boolean got is true:", ok) ok = t.JSON(42, `42`, nil) fmt.
Show HN: Go-testdeep, testing JSON content in Golang



Send Feedback | WebAssembly Version (beta)