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

https://github.com/goapt/test

golang unit testing tools
https://github.com/goapt/test

Last synced: 10 months ago
JSON representation

golang unit testing tools

Awesome Lists containing this project

README

          

## Golang unit testing tools

Build Status
codecov
Go Report Card
<br />
GoDoc

```go
go get github.com/goapt/test
```

### HTTP Mock

```go
var httpSuites = []test.HttpClientSuite{
{
URI: "/test",
ResponseBody: `{"retcode":200}`,
},
}

func TestLoginHandle(t *testing.T) {
httpClient := test.NewHttpClientSuite(httpSuites)
resp, err := httpClient.Post("https://dummy.impl/test",test.JsonContentType,strings.NewReader(""))
assert.NoError(t, err)
if err == nil {
body, err := ioutil.ReadAll(resp.Body)
assert.NoError(t, err)
assert.Equal(t, `{"retcode":200}`, string(body))
}
}
```

### Redis memory server
Based on the [github.com/alicebob/miniredis](https://github.com/alicebob/miniredis)

```go
rds := test.NewRedis()
```

### Gee handler test

```go
req := test.NewRequest("/test", func(c *gee.Context) gee.Response {
return c.String("ok")
})

```