chore: initialize Gitea v1.27.2 fork
giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Includes direct password setup links in registration emails. Assisted-by: Codex:GPT-5
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package actions
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.com/gitea/runner/act/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCoerceDispatchInputTypes(t *testing.T) {
|
||||
dispatch := &model.WorkflowDispatch{
|
||||
Inputs: map[string]model.WorkflowDispatchInput{
|
||||
"build_server": {Type: "boolean"},
|
||||
"dry_run": {Type: "boolean"},
|
||||
"already_bool": {Type: "boolean"},
|
||||
"yaml_true": {Type: "boolean"},
|
||||
"yaml_truthy": {Type: "boolean"},
|
||||
"version": {Type: "string"},
|
||||
},
|
||||
}
|
||||
|
||||
inputs := map[string]any{
|
||||
// dispatch callbacks fill booleans as strconv.FormatBool(...) strings
|
||||
"build_server": "true",
|
||||
"dry_run": "false",
|
||||
// already-native booleans are passed through unchanged (coercion is idempotent)
|
||||
"already_bool": true,
|
||||
// source text of `default: True` and `default: yes`, only the former is a YAML 1.2 boolean
|
||||
"yaml_true": "True",
|
||||
"yaml_truthy": "yes",
|
||||
// non-boolean inputs must be left untouched
|
||||
"version": "1.2.3",
|
||||
}
|
||||
|
||||
coerceDispatchInputTypes(dispatch, inputs)
|
||||
|
||||
// Regression: without coercion these stay strings, and a server-side needs-gated
|
||||
// job `if: inputs.build_server == true` never matches, leaving the job blocked.
|
||||
assert.Equal(t, true, inputs["build_server"])
|
||||
assert.Equal(t, false, inputs["dry_run"])
|
||||
assert.Equal(t, true, inputs["already_bool"])
|
||||
assert.Equal(t, true, inputs["yaml_true"])
|
||||
assert.Equal(t, false, inputs["yaml_truthy"])
|
||||
assert.Equal(t, "1.2.3", inputs["version"])
|
||||
|
||||
// `github.event.inputs` mirrors them as normalized strings
|
||||
assert.Equal(t, map[string]any{
|
||||
"build_server": "true",
|
||||
"dry_run": "false",
|
||||
"already_bool": "true",
|
||||
"yaml_true": "true",
|
||||
"yaml_truthy": "false",
|
||||
"version": "1.2.3",
|
||||
}, dispatchEventInputs(inputs))
|
||||
}
|
||||
Reference in New Issue
Block a user