我想编写测试代码以验证正确的文档以到达第三方服务器的 Oauth2.0,我应该如何完成伪代码?
import (
"net/http"
"net/http/httptest"
}
func testAuthServer(t *testing.T) {
form := url.Values{}
form.Set(...)
r := httptest.NewRequest(http.MethodPost, authUrl, strings.NewReader(form.Encode()))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
w := httptest.NewRecorder()
// test the auth server
if w.Code != http.StatusOK {
...
}
}