我一直在寻找答案,但找不到它。我的问题是,是否有可能测试依赖动态URL标记的处理函数?测试处理器依靠Go中的动态URL的功能
例如,可以说我的处理程序函数需要动态生成的URL中的令牌(我不知道如何生成令牌,也不能从URL参数中访问它)。我的URL将永远是这个样子:www.example.com/?token=randomtokenhere
func TokenProcessing(w http.ResponseWriter, r *http.Request) {
token := r.URL.Query().Get("token") // dynamically generated from parsed URL
// code to do something with said token
}
可能以某种方式进行单元测试这个处理函数没有获得如何创建令牌?