h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
https://pkg.go.dev/github.com/h2non/gock
MIT License
2.04k stars 106 forks source link

Matching an array in the request body #105

Open collimarco opened 1 year ago

collimarco commented 1 year ago

I cannot match an array in the JSON request body.

gock.New("https://example.com").
    Post("/api/v1/projects/PROJECT_ID/notifications").
    MatchType("json").
    JSON(map[string]interface{}{"body": "Hello user1", "uids": []string{"user1"}}).
    Reply(201)

It seems that JSON matching works only with type map[string]string but not with more complex objects (like array fields).

I always get: gock: cannot match any request.

Any suggestions?

Thank you