1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

chore: modernize code (#857)

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/857
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Michael Kriese 2025-08-15 04:54:13 +00:00 committed by Michael Kriese
parent 886bf2a4f3
commit 27f425987c
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
49 changed files with 316 additions and 363 deletions

View file

@ -261,66 +261,66 @@ func TestParseMappingNode(t *testing.T) {
tests := []struct {
input string
scalars []string
datas []interface{}
datas []any
}{
{
input: "on:\n push:\n branches:\n - master",
scalars: []string{"push"},
datas: []interface{}{
map[string]interface{}{
"branches": []interface{}{"master"},
datas: []any{
map[string]any{
"branches": []any{"master"},
},
},
},
{
input: "on:\n branch_protection_rule:\n types: [created, deleted]",
scalars: []string{"branch_protection_rule"},
datas: []interface{}{
map[string]interface{}{
"types": []interface{}{"created", "deleted"},
datas: []any{
map[string]any{
"types": []any{"created", "deleted"},
},
},
},
{
input: "on:\n project:\n types: [created, deleted]\n milestone:\n types: [opened, deleted]",
scalars: []string{"project", "milestone"},
datas: []interface{}{
map[string]interface{}{
"types": []interface{}{"created", "deleted"},
datas: []any{
map[string]any{
"types": []any{"created", "deleted"},
},
map[string]interface{}{
"types": []interface{}{"opened", "deleted"},
map[string]any{
"types": []any{"opened", "deleted"},
},
},
},
{
input: "on:\n pull_request:\n types:\n - opened\n branches:\n - 'releases/**'",
scalars: []string{"pull_request"},
datas: []interface{}{
map[string]interface{}{
"types": []interface{}{"opened"},
"branches": []interface{}{"releases/**"},
datas: []any{
map[string]any{
"types": []any{"opened"},
"branches": []any{"releases/**"},
},
},
},
{
input: "on:\n push:\n branches:\n - main\n pull_request:\n types:\n - opened\n branches:\n - '**'",
scalars: []string{"push", "pull_request"},
datas: []interface{}{
map[string]interface{}{
"branches": []interface{}{"main"},
datas: []any{
map[string]any{
"branches": []any{"main"},
},
map[string]interface{}{
"types": []interface{}{"opened"},
"branches": []interface{}{"**"},
map[string]any{
"types": []any{"opened"},
"branches": []any{"**"},
},
},
},
{
input: "on:\n schedule:\n - cron: '20 6 * * *'",
scalars: []string{"schedule"},
datas: []interface{}{
[]interface{}{map[string]interface{}{
datas: []any{
[]any{map[string]any{
"cron": "20 6 * * *",
}},
},
@ -332,7 +332,7 @@ func TestParseMappingNode(t *testing.T) {
workflow, err := model.ReadWorkflow(strings.NewReader(test.input), false)
assert.NoError(t, err)
scalars, datas, err := parseMappingNode[interface{}](&workflow.RawOn)
scalars, datas, err := parseMappingNode[any](&workflow.RawOn)
assert.NoError(t, err)
assert.EqualValues(t, test.scalars, scalars, fmt.Sprintf("%#v", scalars))
assert.EqualValues(t, test.datas, datas, fmt.Sprintf("%#v", datas))
@ -423,15 +423,15 @@ func TestEvaluateConcurrency(t *testing.T) {
map[string]any{
"workflow": "test_workflow",
"ref": "main",
"event": map[string]interface{}{
"commits": []interface{}{
map[string]interface{}{
"author": map[string]interface{}{
"event": map[string]any{
"commits": []any{
map[string]any{
"author": map[string]any{
"username": "someone",
},
},
map[string]interface{}{
"author": map[string]interface{}{
map[string]any{
"author": map[string]any{
"username": "someone-else",
},
},