vendredi 12 février 2021

Golang test data - "actual : *json.SyntaxError(&json.SyntaxError{msg:"unexpected end of JSON input", Offset:0})"

In my go test code, I've mocked some sample json data as a strings.NewReader as it is easier to test than using static files. The tests runs fine when you click on the run test button next to the test case in VScode. But when I do go test ./..., I get the error that complains about the json file: actual : *json.SyntaxError(&json.SyntaxError{msg:"unexpected end of JSON input", Offset:0})

The json mock data looks fine below to me, is the problem still with json mock data?

var parseTestData = strings.NewReader(`[
{
  "id": 1,
  "url": "www.a.com",
  "created_at": "2020-05-21T11:11:28 -10:00",
  "details": "I don't know",
  "paid": false,
},
{
  "id": 2,
  "url": "www.b.com",
  "created_at": "2021-05-21T11:11:28 10:00",
  "details": "hello",
  "paid": true,
}
]`)

Aucun commentaire:

Enregistrer un commentaire