adjust tests (7)

This commit is contained in:
6543 2024-10-31 21:59:36 +01:00
parent b2dbc98f8f
commit 3559d2f142
4 changed files with 10 additions and 8 deletions

View File

@ -152,7 +152,7 @@ func testLinksAsUser(userName string, t *testing.T) {
DecodeJSON(t, respAPI, &apiRepos) DecodeJSON(t, respAPI, &apiRepos)
repoLinks := []string{ repoLinks := []string{
"", "/code",
"/issues", "/issues",
"/pulls", "/pulls",
"/commits/branch/master", "/commits/branch/master",

View File

@ -63,7 +63,7 @@ func TestLimitedOrg(t *testing.T) {
session := loginUser(t, "user2") session := loginUser(t, "user2")
req = NewRequest(t, "GET", "/limited_org") req = NewRequest(t, "GET", "/limited_org")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/limited_org/public_repo_on_limited_org") req = NewRequest(t, "GET", "/limited_org/public_repo_on_limited_org/code")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/limited_org/private_repo_on_limited_org") req = NewRequest(t, "GET", "/limited_org/private_repo_on_limited_org")
session.MakeRequest(t, req, http.StatusNotFound) session.MakeRequest(t, req, http.StatusNotFound)
@ -72,7 +72,7 @@ func TestLimitedOrg(t *testing.T) {
session = loginUser(t, "user1") session = loginUser(t, "user1")
req = NewRequest(t, "GET", "/limited_org") req = NewRequest(t, "GET", "/limited_org")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/limited_org/public_repo_on_limited_org") req = NewRequest(t, "GET", "/limited_org/public_repo_on_limited_org/code")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/limited_org/private_repo_on_limited_org") req = NewRequest(t, "GET", "/limited_org/private_repo_on_limited_org")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
@ -102,7 +102,7 @@ func TestPrivateOrg(t *testing.T) {
session = loginUser(t, "user4") session = loginUser(t, "user4")
req = NewRequest(t, "GET", "/privated_org") req = NewRequest(t, "GET", "/privated_org")
session.MakeRequest(t, req, http.StatusNotFound) session.MakeRequest(t, req, http.StatusNotFound)
req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org") // colab of this repo req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org/code") // colab of this repo
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org") req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
session.MakeRequest(t, req, http.StatusNotFound) session.MakeRequest(t, req, http.StatusNotFound)
@ -111,9 +111,9 @@ func TestPrivateOrg(t *testing.T) {
session = loginUser(t, "user1") session = loginUser(t, "user1")
req = NewRequest(t, "GET", "/privated_org") req = NewRequest(t, "GET", "/privated_org")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org") req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org/code")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org") req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org/code")
session.MakeRequest(t, req, http.StatusOK) session.MakeRequest(t, req, http.StatusOK)
} }

View File

@ -69,7 +69,9 @@ func TestRepoForkToOrg(t *testing.T) {
// Check that no more forking is allowed as user2 owns repository // Check that no more forking is allowed as user2 owns repository
// and org3 organization that owner user2 is also now has forked this repository // and org3 organization that owner user2 is also now has forked this repository
req := NewRequest(t, "GET", "/user2/repo1") req := NewRequest(t, "GET", "/user2/repo1")
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusMovedPermanently)
req = NewRequest(t, "GET", resp.Result().Header.Get("Location"))
resp = MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body) htmlDoc := NewHTMLParser(t, resp.Body)
_, exists := htmlDoc.doc.Find(`a.ui.button[href*="/fork"]`).Attr("href") _, exists := htmlDoc.doc.Find(`a.ui.button[href*="/fork"]`).Attr("href")
assert.False(t, exists, "Forking should not be allowed anymore") assert.False(t, exists, "Forking should not be allowed anymore")

View File

@ -25,7 +25,7 @@ func TestViewRepo(t *testing.T) {
session := loginUser(t, "user2") session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1") req := NewRequest(t, "GET", "/user2/repo1")
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusMovedPermanently)
link := resp.Result().Header.Get("Location") link := resp.Result().Header.Get("Location")
req = NewRequest(t, "GET", link) req = NewRequest(t, "GET", link)