2024-12-14 10:22:30 +08:00
|
|
|
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2025-01-15 21:34:30 +08:00
|
|
|
package actions
|
2024-12-14 10:22:30 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
actions_model "code.gitea.io/gitea/models/actions"
|
|
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2025-01-15 21:34:30 +08:00
|
|
|
func TestFindTaskNeeds(t *testing.T) {
|
2024-12-14 10:22:30 +08:00
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
|
|
|
|
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 51})
|
2025-01-15 21:34:30 +08:00
|
|
|
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: task.JobID})
|
2024-12-14 10:22:30 +08:00
|
|
|
|
2025-01-15 21:34:30 +08:00
|
|
|
ret, err := FindTaskNeeds(context.Background(), job)
|
2024-12-14 10:22:30 +08:00
|
|
|
assert.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"])
|
|
|
|
}
|