fix tests

This commit is contained in:
Nicolas committed 2026-03-31 21:58:30 +02:00
1 parent b7ae17c92a
commit 00efb1af42
2 files changed
+16 -3

No files matched your search

+15 -2
View File
@@ -709,8 +709,21 @@ func getCurrentRunJobsByPathParam(ctx *context_module.Context) (*actions_model.A
}
func getCurrentRunAndUploadedArtifacts(ctx *context_module.Context, artifactName string) (*actions_model.ActionRun, []*actions_model.ActionArtifact, bool) {
run := getCurrentRunByPathParam(ctx)
if ctx.Written() {
var (
run *actions_model.ActionRun
err error
)
if ctx.PathParam("run") == "latest" {
run, err = actions_model.GetLatestRun(ctx, ctx.Repo.Repository.ID)
} else {
run, err = actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("run"))
}
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.HTTPError(http.StatusNotFound, err.Error())
return nil, nil, false
}
ctx.ServerError("GetRunByIndex", err)
return nil, nil, false
}
@@ -35,7 +35,7 @@ func TestActionsArtifactPreviewSingleFile(t *testing.T) {
req := NewRequestf(t, "GET", "/%s/actions/runs/187/artifacts/artifact-download/preview", repo.FullName())
resp := session.MakeRequest(t, req, http.StatusOK)
assert.Contains(t, resp.Body.String(), "abc.txt")
assert.Contains(t, resp.Body.String(), "/preview/raw?path=abc.txt")
assert.Contains(t, resp.Body.String(), "/preview/raw/abc.txt")
req = NewRequestf(t, "GET", "/%s/actions/runs/187/artifacts/artifact-download/preview/raw", repo.FullName())
resp = session.MakeRequest(t, req, http.StatusOK)