我写了一个 cookie getter 和 setter。现在我想测试它,并编写了以下测试函数。func TestAuthorizationReader(t *testing.T) {    tw := httptest.NewServer(testWriter())    tr := httptest.NewServer(Use(testReader()))    defer tw.Close()    defer tr.Close()    c := &http.Client{}    rs, err := c.Get(tw.URL)    assert.NoError(t, err, "Should not contain any error")    // Assign cookie to client    url, err := rs.Location()    fmt.Print(url)    assert.NoError(t, err, "Should not contain any error")    //c.Jar.SetCookies(url, rs.Cookies())}测试在第二部分失败,作为我得到的输出消息- FAIL: TestAuthorizationReader (0.05s) Location:       logged_test.go:64 Error:          No error is expected but got http: no Location header in response Messages:       Should not contain any error我无法获得 URL 位置指针,我在这里做错了什么?
                    
                    
                1 回答
- 1 回答
 - 0 关注
 - 228 浏览
 
添加回答
举报
0/150
	提交
		取消
	