This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package ginext
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRedirectFound(t *testing.T) {
|
||||
hf := RedirectFound("/x")
|
||||
resp := hf(PreContext{})
|
||||
if resp == nil {
|
||||
t.Fatalf("expected response")
|
||||
}
|
||||
if resp.(InspectableHTTPResponse).Statuscode() != http.StatusFound {
|
||||
t.Fatalf("expected 302")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRedirectTemporary(t *testing.T) {
|
||||
hf := RedirectTemporary("/x")
|
||||
resp := hf(PreContext{})
|
||||
if resp.(InspectableHTTPResponse).Statuscode() != http.StatusTemporaryRedirect {
|
||||
t.Fatalf("expected 307")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRedirectPermanent(t *testing.T) {
|
||||
hf := RedirectPermanent("/x")
|
||||
resp := hf(PreContext{})
|
||||
if resp.(InspectableHTTPResponse).Statuscode() != http.StatusPermanentRedirect {
|
||||
t.Fatalf("expected 308")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user