The highest tagged major version is
v9.
package
Version:
v6.2.0
Opens a new window with list of versions in this module.
Published: Jun 20, 2022
License: MIT
Opens a new window with license information.
Imports: 10
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package routertest 提供针对路由的测试用例
NOTE: 只提供针对不同的类型参数 T 可能造成不周结果的测试。
type Tester[T any] struct {
}
func NewTester[T any](c mux.CallOf[T]) *Tester[T]
Bench 执行所有的性能测试
h 表示路由的处理函数,只要向终端输出 URL.Path 值即可,
以 T 的类型为 http.HandlerFunc 为例:
func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(r.URL.Path))
}
func (t *Tester[T]) Params(a *assert.Assertion, f func(params *mux.Params) T)
Params 测试参数是否正常
f 返回一个路由处理函数,该函数必须要将获得的参数写入 params.
func (t *Tester[T]) Serve(a *assert.Assertion, h func(status int) T)
Serve 测试路由是否正常
h 返回路由处理函数,该函数只要输出 status 作为其状态码即可。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.