Hi,
I have a function streaming a zipreader to browser. It is like this.
func functionA(....)(body io.ReadCloser, err error){

   // some logic to get a zipreader

   body, pipeWriter := io.Pipe()
   zipWriter := zip.NewWriter(pipeWriter)

   go func(){
      // err := functionB(zipReader, zipWriter)call another function to 
prepare files and write to zipwriter
   If err != nil{
       zipWriter.Close()
        _ = pipeWriter.CloseWithError(err)
        return
   }
      zipWriter.Close()
       pipeWriter.Close()
   }()
   return 
}

My question is about unit test about this functionA. I have mock for 
functionB. How do I write unit test for functionA with the mock functionB. 
It seems my unit test does not work well when it goes into the goroutine.
Many thanks!

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4ca0817a-f1f7-44a9-be3d-3584bcb61b8an%40googlegroups.com.

Reply via email to