kataras / kataras/iris

How to disable auto redirect in httptest?

Open
#1,775 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I have api router need `ctx.Redirect(targetURL, statusCode)`, I want to check the `targetURL` is ok,
```
app.get("/a", func(ctx iris.Context){
ctx.Redirect("https://google.com", 302)
})
```

i write test like :

```
func TestCreate(t *testing.T) {
t.Run("301 check", func(t *testing.T) {
e := httptest.New(t, TestServer)
tt := e.GET("/a").
response := tt.Expect()
response.Status(301)
fmt.Println(response.Header("Location").Raw())
})
}
```
the http request will request `google.com` but it's not my expect result, i just want to get 301 and the text in http header `location`
how to disable request auto redirect and let test pass?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.