I wouldn’t test that, test what is producing the response and that it is the 
correct format. The testing of the encoding if the response is all that is 
warranted - the other is tested in an integration test. 

> On Apr 1, 2019, at 8:07 AM, aniruddha.dwiv...@nytimes.com wrote:
> 
> Hi, 
> 
> I am writing test cases in golang for one of service used in my organisation. 
> In one of file, I have below method --
> 
> 
> func encodeEdgeResp(_ context.Context, w http.ResponseWriter, response 
> interface{}) error {
>       w.Header().Set("Content-Type", "application/json; charset=utf-8")
>       return json.NewEncoder(w).Encode(response)
> }
> 
> 
> I am unable to understand how can I pass/mock http.ResponseWriter over here 
> to run my test cases.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to