httpmock:Golang的HTTP模拟

时间:2021-04-05 15:07:28
【文件属性】:
文件名称:httpmock:Golang的HTTP模拟
文件大小:22KB
文件格式:ZIP
更新时间:2021-04-05 15:07:28
go mock golang Go Golang的HTTP模拟 httpmock是一个实现的模拟库,以支持HTTP行为测试。 先决条件 Go >= 1.14 安装 go get github.com/nhatthm/httpmock 例子 func Test_Simple ( t * testing. T ) { mockServer := httpmock . New ( func ( s * httpmock. Server ) { s . Expect ( http . MethodGet , "/" ). Return ( "hello world!" ) }) s := mockServer ( t ) code , _ , body , _ := httpmock . DoRequest ( t , http . MethodGet , s . URL + "/" , nil , nil )
【文件预览】:
httpmock-master
----server.go(5KB)
----error.go(2KB)
----doc.go(87B)
----helper_test.go(2KB)
----.github()
--------workflows()
----server_test.go(12KB)
----.golangci.yaml(795B)
----mock.go(1KB)
----resources()
--------fixtures()
----LICENSE(1KB)
----helper.go(4KB)
----mock_test.go(1KB)
----request_test.go(6KB)
----.gitignore(283B)
----Makefile(346B)
----go.sum(1024B)
----matcher_test.go(5KB)
----matcher.go(5KB)
----README.md(3KB)
----request.go(8KB)
----go.mod(88B)

网友评论