mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-21 18:10:56 +00:00
Move some Actions related functions from routers
to services
(#33280)
Move the main logic of `generateTaskContext` and `findTaskNeeds` to the `services` layer. This is a part of #32751, since we need the git context and `needs` to parse the concurrency expressions. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit d0962ce3da424f0a1df2acf595b20066d6e55128) Conflicts: routers/api/actions/runner/main_test.go routers/api/actions/runner/utils.go services/actions/context_test.go services/actions/init_test.go tests/integration/actions_job_test.go simple conflicts related to ref_type": string(refName.RefType()), // string, The type of ref that triggered the workflow run. Valid values are branch or tag. Use env GITEA_RUNNER_REGISTRATION_TOKEN as global runner token (#32946)
This commit is contained in:
parent
6ffa454979
commit
06dfcc1a45
4 changed files with 271 additions and 136 deletions
30
services/actions/context_test.go
Normal file
30
services/actions/context_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package actions
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFindTaskNeeds(t *testing.T) {
|
||||
require.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 51})
|
||||
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: task.JobID})
|
||||
|
||||
ret, err := FindTaskNeeds(context.Background(), job)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, ret, 1)
|
||||
assert.Contains(t, ret, "job1")
|
||||
assert.Len(t, ret["job1"].Outputs, 2)
|
||||
assert.Equal(t, "abc", ret["job1"].Outputs["output_a"])
|
||||
assert.Equal(t, "bbb", ret["job1"].Outputs["output_b"])
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue