An open API service indexing awesome lists of open source software.

https://github.com/theypsilon/go-httpmock

Utility for mocking the net/http package of the Go language
https://github.com/theypsilon/go-httpmock

Last synced: 9 months ago
JSON representation

Utility for mocking the net/http package of the Go language

Awesome Lists containing this project

README

          

httpmock.go ![Build Status](https://travis-ci.org/theypsilon/go-httpmock.svg?branch=master)
======

Simple utility, for mocking http connections. Work 90% based on this gist: https://gist.github.com/jarcoal/8940980

```go
// in a gopkg.in/check.v1 test method:
RegisterResponder("GET", "http://example.com/", func(*http.Request) (*http.Response, error) {
return GetResponseWithBody("xin chao"), nil
})

response, _ := http.Get("http://example.com/")

c.Assert(BodyToString(response), checker.Equals, "xin chao")
```