mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-13 11:05:46 +02:00
Fix test
This commit is contained in:
parent
fd1afc5e4c
commit
a4aae82c18
@ -5,6 +5,7 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
@ -189,13 +190,24 @@ func testActionsTokenPermissionsMode(u *url.URL, mode string, expectReadOnly boo
|
|||||||
context.ExpectedCode = util.Iif(expectReadOnly, http.StatusForbidden, http.StatusNoContent)
|
context.ExpectedCode = util.Iif(expectReadOnly, http.StatusForbidden, http.StatusNoContent)
|
||||||
if !expectReadOnly {
|
if !expectReadOnly {
|
||||||
// Clean up created file if we had write access
|
// Clean up created file if we had write access
|
||||||
t.Run("API Delete File", doAPIDeleteFile(context, "test-permissions.txt", &structs.DeleteFileOptions{
|
t.Run("API Delete File", func(t *testing.T) {
|
||||||
FileOptions: structs.FileOptions{
|
t.Logf("Deleting file with SHA: %s", sha)
|
||||||
BranchName: "new-branch-permissions",
|
require.NotEmpty(t, sha, "SHA must be captured before deletion")
|
||||||
Message: "Delete File",
|
deleteOpts := &structs.DeleteFileOptions{
|
||||||
},
|
FileOptions: structs.FileOptions{
|
||||||
SHA: sha,
|
BranchName: "new-branch-permissions",
|
||||||
}))
|
Message: "Delete File",
|
||||||
|
},
|
||||||
|
SHA: sha,
|
||||||
|
}
|
||||||
|
req := NewRequestWithJSON(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", context.Username, context.Reponame, "test-permissions.txt"), deleteOpts).
|
||||||
|
AddTokenAuth(context.Token)
|
||||||
|
if context.ExpectedCode != 0 {
|
||||||
|
context.Session.MakeRequest(t, req, context.ExpectedCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
context.Session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user