adjust tests (5)

This commit is contained in:
6543 2024-10-31 21:42:49 +01:00
parent 924e3d5f52
commit 40aae71221
1 changed files with 14 additions and 2 deletions

View File

@ -55,8 +55,6 @@ func TestRedirectsNoLogin(t *testing.T) {
"/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
"/user/avatar/Ghost/-1": "/assets/img/avatar_default.png",
"/api/v1/swagger": "/api/swagger",
"/user2/repo1": "/user2/repo1/code",
"/user2/repo1/": "/user2/repo1/code",
}
for link, redirectLink := range redirects {
req := NewRequest(t, "GET", link)
@ -65,6 +63,20 @@ func TestRedirectsNoLogin(t *testing.T) {
}
}
func TestPermanentRedirectsNoLogin(t *testing.T) {
defer tests.PrepareTestEnv(t)()
redirects := map[string]string{
"/user2/repo1": "/user2/repo1/code",
"/user2/repo1/": "/user2/repo1/code",
}
for link, redirectLink := range redirects {
req := NewRequest(t, "GET", link)
resp := MakeRequest(t, req, http.StatusMovedPermanently)
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
}
}
func TestNoLoginNotExist(t *testing.T) {
defer tests.PrepareTestEnv(t)()