34 lines
728 B
Go
34 lines
728 B
Go
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")
|
|
}
|
|
}
|