Add redirect param to user config

This commit is contained in:
2023-09-03 09:41:00 +02:00
parent ec33b402b9
commit 80cbf9210d
4 changed files with 31 additions and 0 deletions

View File

@ -141,3 +141,23 @@ func TestCorrectResponseForUserConfig(t *testing.T) {
t.Errorf("returned image does not match expected image for mapped alias '42'")
}
}
func TestCorrectRedirect(t *testing.T) {
configure("./testdata/testconfig.toml")
req, err := http.NewRequest("GET", "/avatar/example2", nil)
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
testRouter().ServeHTTP(rr, req)
if code := rr.Code; code != http.StatusFound {
t.Errorf("response code match: got %d want %d", code, http.StatusFound)
}
if location := rr.Header().Get("Location"); location != "https://avatars.example.com/u/42" {
t.Errorf("location header does not match: got %v want https://avatars.example.com/u/42", location)
}
}