title: How to test http calls in go
body: <p>I have the following code:</p>
  
  <pre><code>// HTTPPost to post json messages to the specified url
  func HTTPPost(message interface{}, url string) (*http.Response, error) {
      jsonValue, err := json.Marshal(message)
      if err != nil {
          logger.Error("Cannot Convert to JSON: ", err)
          return nil, err
      }
      logger.Info("Calling http post with url: ", url)
      resp, err := getClient().Post(url, "application/json", bytes.NewBuffer(jsonValue))
      if err != nil {
          logger.Error("Cannot post to the url: ", url, err)
          return nil, err
      }
      err = IsErrorResp(resp, url)
      return resp, err
  }
  </code></pre>
  
  <p>I'd like to write the tests for this, but I am not sure how to use httptest package .   </p>