Files
goext/ginext/commonHandler_test.go
T
Mikescher 02d6894ec6
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m34s
[🤖] Add Unit-Tests
2026-04-27 16:31:29 +02:00

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")
}
}