# README
Golang unit testing tools
go get github.com/goapt/test
HTTP Mock
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
rds := test.NewRedis()
Gee handler test
req := test.NewRequest("/test", func(c *gee.Context) gee.Response {
return c.String("ok")
})
# Functions
Config 加载测试私密文件.
NewTestHttpClient returns *http.Client with Transport replaced to avoid making real calls.
NewHttpClientSuite quickly define HTTP Response for mock.
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
专供测试使用的RSA密钥对.
# Structs
HttpClientSuite is test set for http client URI is need to match request uri MatchBody is need to match request body, The key of the Map is the JSON path, map["goods_defail.goods_id":"1"] MatchQuery is need to match request query params ResponseBody is http return body StatusCode is http status Header is response headers Error mock request exception.
No description provided by the author
No description provided by the author
# Type aliases
RoundTripFunc .