Reputation: 77
The function I'm testing is returning JSON. How can I write the exact JSON object I expect in the want field?
tests := []struct {
name string
args args
want string
}{
{
name: "success",
args: args{ "XXX", "XXX" },
want: "XXX",
},
Upvotes: 1
Views: 50
Reputation: 144
Your example is sufficient if you enclose the JSON into a block, i.e.:
var tests = []struct {
name string
args args
want string
}{
{
name: "success",
args: args{ "XXX", "XXX" },
want: `
{
"example": [
{
"name": "example",
"inputs": [],
"outputs": [],
}
]
}
`,
},
}
Upvotes: 1