forgejo/services/actions/workflows_test.go
Renovate Bot d2bde42347
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Update module code.forgejo.org/forgejo/runner/v11 to v12 (forgejo) (#10213)
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [code.forgejo.org/forgejo/runner/v11](https://code.forgejo.org/forgejo/runner) | `v11.3.1` -> `v12.0.1` | [![age](https://developer.mend.io/api/mc/badges/age/go/code.forgejo.org%2fforgejo%2frunner%2fv11/v12.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/code.forgejo.org%2fforgejo%2frunner%2fv11/v11.3.1/v12.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>forgejo/runner (code.forgejo.org/forgejo/runner/v11)</summary>

### [`v12.0.1`](https://code.forgejo.org/forgejo/runner/releases/tag/v12.0.1)

[Compare Source](https://code.forgejo.org/forgejo/runner/compare/v12.0.0...v12.0.1)

- [User guide](https://forgejo.org/docs/next/user/actions/overview/)
- [Administrator guide](https://forgejo.org/docs/next/admin/actions/)
- [Container images](https://code.forgejo.org/forgejo/-/packages/container/runner/versions)

Release Notes

***

<!--start release-notes-assistant-->

<!--URL:https://code.forgejo.org/forgejo/runner-->

- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1175): <!--number 1175 --><!--line 0 --><!--description Zml4OiAnZmFpbGVkIHRvIHJlYWQgYWN0aW9uJyBlcnJvcnMgd2hlbiB1c2luZyByZWxhdGl2ZSB3b3JrZGlyX3BhcmVudA==-->fix: 'failed to read action' errors when using relative workdir\_parent<!--description-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1176): <!--number 1176 --><!--line 0 --><!--description Y2hvcmU6IGJ1bXAgdmVyc2lvbiB0byB2MTI=-->chore: bump version to v12<!--description-->

<!--end release-notes-assistant-->

### [`v12.0.0`](https://code.forgejo.org/forgejo/runner/releases/tag/v12.0.0)

[Compare Source](https://code.forgejo.org/forgejo/runner/compare/v11.3.1...v12.0.0)

- [User guide](https://forgejo.org/docs/next/user/actions/overview/)
- [Administrator guide](https://forgejo.org/docs/next/admin/actions/)
- [Container images](https://code.forgejo.org/forgejo/-/packages/container/runner/versions)

Release Notes

**Breaking change:** This release is a major version bump due to a system requirement change, requiring a git installation.  This requirement is included in the OCI containers, but may require the installation of a supported package, or packaging changes from redistributors of Forgejo Runner.  Access to a `git` binary is now required to access reusable actions and workflows, such as `use: action/checkout@v5` -- before this release, access was performed using an internal library that avoided an external dependency.  [PR](https://code.forgejo.org/forgejo/runner/pulls/1162)

***

<!--start release-notes-assistant-->

<!--URL:https://code.forgejo.org/forgejo/runner-->

- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1173): <!--number 1173 --><!--line 0 --><!--description ZmVhdDogYWRkIGNvbmZpZyB2YWx1ZXMgdG8gb3ZlcnJpZGUgdGFzayBmaW5hbGl6YXRpb24gcmV0cnk=-->feat: add config values to override task finalization retry<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1160): <!--number 1160 --><!--line 0 --><!--description ZmVhdDogc2tpcCBmZXRjaGluZyByZW1vdGUgYWN0aW9uIHJlcG8gd2hlbiB1c2luZyBmdWxsIHNoYSBhbHJlYWR5IGZldGNoZWQ=-->feat: skip fetching remote action repo when using full sha already fetched<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1162): <!--number 1162 --><!--line 0 --><!--description ZmVhdDogdXNlIGdpdCB3b3JrIHRyZWVzIGZvciByZW1vdGUgZ2l0IGFjdGlvbnMgJiB3b3JrZmxvd3M=-->feat: use git work trees for remote git actions & workflows<!--description-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1170): <!--number 1170 --><!--line 0 --><!--description Zml4OiBpbXByb3ZlIGxvZ2dpbmcgb24gZmluYWwgbG9nICYgc3RhdHVzIHRyYW5zbWlzc2lvbiBhbmQgcmV0cmllcw==-->fix: improve logging on final log & status transmission and retries<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1135): <!--number 1135 --><!--line 0 --><!--description Zml4OiBlbmFibGUgYnVpbGRpbmcgZm9yIG9wZW5ic2QsIGRyYWdvbmZseSwgYW5kIHNvbGFyaXMvaWxsdW1vcw==-->fix: enable building for openbsd, dragonfly, and solaris/illumos<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1136): <!--number 1136 --><!--line 0 --><!--description Zml4OiBpbml0aWFsaXplIHdvcmtmbG93LWxldmVsIGVudiBjb250ZXh0IGJlZm9yZSBzdGFydGluZyBqb2IgY29udGFpbmVy-->fix: initialize workflow-level env context before starting job container<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1137): <!--number 1137 --><!--line 0 --><!--description Zml4OiBhbGxvdyAnZW52JyBjb250ZXh0IGluIGpvYnMuPG5hbWU+Lmlm-->fix: allow 'env' context in jobs.<name>.if<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1145): <!--number 1145 --><!--line 0 --><!--description Zml4OiByZW1vdGUgcmV1c2FibGUgd29ya2Zsb3dzIGJ5IHJlbGF0aXZlIFVSTCB1c2UgZGVmYXVsdF9hY3Rpb25zX3VybA==-->fix: remote reusable workflows by relative URL use default\_actions\_url<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1156): <!--number 1156 --><!--line 0 --><!--description Zml4OiBVc2UgZ2l0IHJlc2V0IC0taGFyZCBpbnN0ZWFkIG9mIHB1bGwgYW5kIGNoZWNrb3V0IGZvciBhY3Rpb25z-->fix: Use git reset --hard instead of pull and checkout for actions<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1163): <!--number 1163 --><!--line 0 --><!--description Zml4OiBydW4gaW1hZ2VzIHdpdGggZXhwbGljaXQgcGxhdGZvcm0gdGFncywgZml4ZXMgcHVsbGVkIGltYWdlIGFyY2hpdGVjdHVyZSBtaXNtYXRjaA==-->fix: run images with explicit platform tags, fixes pulled image architecture mismatch<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1165): <!--number 1165 --><!--line 0 --><!--description Zml4OiBpbXByb3ZlIGxvZ2dpbmcgJiBkaXNwbGF5IG9mIGVycm9ycyBkdXJpbmcgd29ya2Zsb3cgZXZhbHVhdGlvbg==-->fix: improve logging & display of errors during workflow evaluation<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1171): <!--number 1171 --><!--line 0 --><!--description Zml4OiBlbnN1cmUgaHR0cC5DbGllbnQgYWx3YXlzIGhhcyBhIHRpbWVvdXQgZm9yIEZvcmdlam8gYWNjZXNz-->fix: ensure http.Client always has a timeout for Forgejo access<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1139): <!--number 1139 --><!--line 0 --><!--description Zml4OiBwYXNzIG9zIGFyZ3VtZW50IHRvIGBseGMtaGVscGVycy5zaGAgaGVscGVyIGZybSBgZm9yZ2Vqby1ydW5uZXItc2VydmljZS5zaGA=-->fix: pass os argument to `lxc-helpers.sh` helper frm `forgejo-runner-service.sh`<!--description-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1155): <!--number 1155 --><!--line 0 --><!--description dGVzdDogYWxsb3cgb3ZlcnJpZGluZyB0aGUgdGVzdCBEb2NrZXIgc29ja2V0IHVzaW5nIERPQ0tFUl9IT1NU-->test: allow overriding the test Docker socket using DOCKER\_HOST<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1152): <!--number 1152 --><!--line 0 --><!--description V2luZG93cyBjb21wYXRpYmlsaXR5IGZpeGVz-->Windows compatibility fixes<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1159): <!--number 1159 --><!--line 0 --><!--description Y2hvcmU6IHJlbW92ZSB1bnVzZWQgYW5kIGluY29tcGxldGUgQWN0aW9uQ2FjaGUgcmV3cml0ZQ==-->chore: remove unused and incomplete ActionCache rewrite<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1168): <!--number 1168 --><!--line 0 --><!--description VXBkYXRlIGdvbGFuZy5vcmcveC9jcnlwdG8gKGluZGlyZWN0KSB0byB2MC40NS4wIFtTRUNVUklUWV0=-->Update golang.org/x/crypto (indirect) to v0.45.0 \[SECURITY]<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1141): <!--number 1141 --><!--line 0 --><!--description VXBkYXRlIG1vZHVsZSBnaXRodWIuY29tL2RvY2tlci9jbGkgdG8gdjI4LjUuMitpbmNvbXBhdGlibGU=-->Update module github.com/docker/cli to v28.5.2+incompatible<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1154): <!--number 1154 --><!--line 0 --><!--description VXBkYXRlIGdvbGFuZy5vcmcveC9jcnlwdG8gKGluZGlyZWN0KSB0byB2MC40My4wIFtTRUNVUklUWV0=-->Update golang.org/x/crypto (indirect) to v0.43.0 \[SECURITY]<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1149): <!--number 1149 --><!--line 0 --><!--description Y2koY2FzY2FkZS1mb3JnZWpvKTogdXNlIHRtcGZzIGZvciBidWlsZGluZyB0byBzcGVlZHVwIGNvbXBpbGF0aW9u-->ci(cascade-forgejo): use tmpfs for building to speedup compilation<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1148): <!--number 1148 --><!--line 0 --><!--description Y2hvcmUocmVub3ZhdGUpOiBhbGxvdyB1cGRhdGluZyBtb3JlIGZvcmdlam8tcnVubmVyLXNlcnZpY2UgZGVwcw==-->chore(renovate): allow updating more forgejo-runner-service deps<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1142): <!--number 1142 --><!--line 0 --><!--description Y2k6IGFsbG93IGdvIHRvIGRvd25sb2FkIHJlcXVpcmVkIHRvb2xjaGFpbiBmb3IgY2FzY2FkZQ==-->ci: allow go to download required toolchain for cascade<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1132): <!--number 1132 --><!--line 0 --><!--description VXBkYXRlIGh0dHBzOi8vZGF0YS5mb3JnZWpvLm9yZy9hY3Rpb25zL3NldHVwLWdvIGFjdGlvbiB0byB2Ng==-->Update <https://data.forgejo.org/actions/setup-go> action to v6<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1140): <!--number 1140 --><!--line 0 --><!--description VXBkYXRlIGh0dHBzOi8vZGF0YS5mb3JnZWpvLm9yZy9hY3Rpb25zL3NldHVwLWZvcmdlam8gYWN0aW9uIHRvIHYzLjAuNQ==-->Update <https://data.forgejo.org/actions/setup-forgejo> action to v3.0.5<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1133): <!--number 1133 --><!--line 0 --><!--description VXBkYXRlIGh0dHBzOi8vZGF0YS5mb3JnZWpvLm9yZy9kb2NrZXIvYnVpbGQtcHVzaC1hY3Rpb24gYWN0aW9uIHRvIHY2-->Update <https://data.forgejo.org/docker/build-push-action> action to v6<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1134): <!--number 1134 --><!--line 0 --><!--description VXBkYXRlIGh0dHBzOi8vZGF0YS5mb3JnZWpvLm9yZy9kb2NrZXIvc2V0dXAtYnVpbGR4LWFjdGlvbiBhY3Rpb24gdG8gdjM=-->Update <https://data.forgejo.org/docker/setup-buildx-action> action to v3<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1131): <!--number 1131 --><!--line 0 --><!--description VXBkYXRlIGh0dHBzOi8vZGF0YS5mb3JnZWpvLm9yZy9hY3Rpb25zL2NoZWNrb3V0IGFjdGlvbiB0byB2NQ==-->Update <https://data.forgejo.org/actions/checkout> action to v5<!--description-->
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1130): <!--number 1130 --><!--line 0 --><!--description VXBkYXRlIGZvcmdlam8tcnVubmVyIHRvIHYxMS4zLjE=-->Update forgejo-runner to v11.3.1<!--description-->

<!--end release-notes-assistant-->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xMS4wIiwidXBkYXRlZEluVmVyIjoiNDIuMTEuMCIsInRhcmdldEJyYW5jaCI6ImZvcmdlam8iLCJsYWJlbHMiOlsiZGVwZW5kZW5jeS11cGdyYWRlIiwidGVzdC9ub3QtbmVlZGVkIl19-->

Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10213
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
2025-11-23 15:58:57 +01:00

275 lines
9.4 KiB
Go

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package actions
import (
"errors"
"testing"
actions_model "forgejo.org/models/actions"
"forgejo.org/models/repo"
"forgejo.org/modules/webhook"
act_model "code.forgejo.org/forgejo/runner/v12/act/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConfigureActionRunConcurrency(t *testing.T) {
for _, tc := range []struct {
name string
concurrency *act_model.RawConcurrency
vars map[string]string
inputs map[string]any
runEvent webhook.HookEventType
expectedConcurrencyGroup string
expectedConcurrencyType actions_model.ConcurrencyMode
}{
// Before the introduction of concurrency groups, push & pull_request_sync would cancel runs on the same repo,
// reference, workflow, and event -- these cases cover undefined concurrency group and backwards compatibility
// checks.
{
name: "backwards compatibility push",
runEvent: webhook.HookEventPush,
expectedConcurrencyGroup: "refs/head/main_testing.yml_push__auto",
expectedConcurrencyType: actions_model.CancelInProgress,
},
{
name: "backwards compatibility pull_request_sync",
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "refs/head/main_testing.yml_pull_request_sync__auto",
expectedConcurrencyType: actions_model.CancelInProgress,
},
{
name: "backwards compatibility other event",
runEvent: webhook.HookEventWorkflowDispatch,
expectedConcurrencyGroup: "refs/head/main_testing.yml_workflow_dispatch__auto",
expectedConcurrencyType: actions_model.UnlimitedConcurrency,
},
{
name: "fully-specified cancel-in-progress",
concurrency: &act_model.RawConcurrency{
Group: "abc",
CancelInProgress: "true",
},
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "abc",
expectedConcurrencyType: actions_model.CancelInProgress,
},
{
name: "fully-specified queue-behind",
concurrency: &act_model.RawConcurrency{
Group: "abc",
CancelInProgress: "false",
},
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "abc",
expectedConcurrencyType: actions_model.QueueBehind,
},
{
name: "no concurrency group, cancel-in-progress: false",
concurrency: &act_model.RawConcurrency{
CancelInProgress: "false",
},
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "refs/head/main_testing.yml_pull_request_sync__auto",
expectedConcurrencyType: actions_model.UnlimitedConcurrency,
},
{
name: "interpreted values",
concurrency: &act_model.RawConcurrency{
Group: "${{ github.workflow }}-${{ github.ref }}",
CancelInProgress: "${{ !contains(github.ref, 'release/')}}",
},
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "testing.yml-refs/head/main",
expectedConcurrencyType: actions_model.CancelInProgress,
},
{
name: "interpreted values with inputs and vars",
concurrency: &act_model.RawConcurrency{
Group: "${{ inputs.abc }}-${{ vars.def }}",
},
inputs: map[string]any{"abc": "123"},
vars: map[string]string{"def": "456"},
runEvent: webhook.HookEventPullRequestSync,
expectedConcurrencyGroup: "123-456",
expectedConcurrencyType: actions_model.CancelInProgress,
},
} {
t.Run(tc.name, func(t *testing.T) {
workflow := &act_model.Workflow{RawConcurrency: tc.concurrency}
run := &actions_model.ActionRun{
Ref: "refs/head/main",
WorkflowID: "testing.yml",
Event: tc.runEvent,
TriggerEvent: string(tc.runEvent),
Repo: &repo.Repository{},
}
err := ConfigureActionRunConcurrency(workflow, run, tc.vars, tc.inputs)
require.NoError(t, err)
if tc.expectedConcurrencyGroup == "" {
assert.Empty(t, run.ConcurrencyGroup, "empty ConcurrencyGroup")
} else {
assert.Equal(t, tc.expectedConcurrencyGroup, run.ConcurrencyGroup)
}
assert.Equal(t, tc.expectedConcurrencyType, run.ConcurrencyType)
})
}
}
func TestResolveDispatchInputAcceptsValidInput(t *testing.T) {
for _, tc := range []struct {
name string
key string
value string
input act_model.WorkflowDispatchInput
expected string
expectedError func(err error) bool
}{
{
name: "on_converted_to_true",
key: "my_boolean",
value: "on",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Type: "boolean", Options: []string{}},
expected: "true",
},
// It might make sense to validate booleans in the future and then turn it into an error.
{
name: "ON_stays_ON",
key: "my_boolean",
value: "ON",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Type: "boolean", Options: []string{}},
expected: "ON",
},
{
name: "true_stays_true",
key: "my_boolean",
value: "true",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Type: "boolean", Options: []string{}},
expected: "true",
},
{
name: "false_stays_false",
key: "my_boolean",
value: "false",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Type: "boolean", Options: []string{}},
expected: "false",
},
{
name: "empty_results_in_default_value_true",
key: "my_boolean",
value: "",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Default: "true", Type: "boolean", Options: []string{}},
expected: "true",
},
{
name: "empty_results_in_default_value_false",
key: "my_boolean",
value: "",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: false, Default: "false", Type: "boolean", Options: []string{}},
expected: "false",
},
{
name: "string_results_in_input",
key: "my_string",
value: "hello",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: false, Type: "string", Options: []string{}},
expected: "hello",
},
{
name: "string_option_results_in_input",
value: "a",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: false, Type: "string", Options: []string{"a", "b"}},
expected: "a",
},
// Test ensures that the old behaviour (ignoring option mismatch) is retained. It might
// make sense to turn it into an error in the future.
{
name: "invalid_string_option_results_in_input",
key: "option",
value: "c",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: false, Type: "string", Options: []string{"a", "b"}},
expected: "c",
},
{
name: "number_results_in_input",
key: "my_number",
value: "123",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: false, Type: "number", Options: []string{}},
expected: "123",
},
{
name: "empty_value_skipped",
key: "my_number",
value: "",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: false, Type: "number", Options: []string{}},
expectedError: func(err error) bool { return errors.Is(err, ErrSkipDispatchInput) },
},
{
name: "required_missing",
key: "my_number",
value: "",
input: act_model.WorkflowDispatchInput{Required: true, Type: "number", Options: []string{}},
expectedError: IsInputRequiredErr,
},
} {
t.Run(tc.name, func(t *testing.T) {
actual, err := resolveDispatchInput(tc.key, tc.value, tc.input)
if tc.expectedError != nil {
assert.True(t, tc.expectedError(err))
} else {
assert.Equal(t, tc.expected, actual)
}
})
}
}
func TestResolveDispatchInputRejectsInvalidInput(t *testing.T) {
for _, tc := range []struct {
name string
key string
value string
input act_model.WorkflowDispatchInput
expected error
}{
{
name: "missing_required_boolean",
key: "missing_boolean",
value: "",
input: act_model.WorkflowDispatchInput{Description: "a boolean", Required: true, Type: "boolean", Options: []string{}},
expected: InputRequiredErr{Name: "a boolean"},
},
{
name: "missing_required_boolean_without_description",
key: "missing_boolean",
value: "",
input: act_model.WorkflowDispatchInput{Required: true, Type: "boolean", Options: []string{}},
expected: InputRequiredErr{Name: "missing_boolean"},
},
{
name: "missing_required_string",
key: "missing_string",
value: "",
input: act_model.WorkflowDispatchInput{Description: "a string", Required: true, Type: "string", Options: []string{}},
expected: InputRequiredErr{Name: "a string"},
},
{
name: "missing_required_string_without_description",
key: "missing_string",
value: "",
input: act_model.WorkflowDispatchInput{Required: true, Type: "string", Options: []string{}},
expected: InputRequiredErr{Name: "missing_string"},
},
} {
t.Run(tc.name, func(t *testing.T) {
_, err := resolveDispatchInput(tc.key, tc.value, tc.input)
assert.Equal(t, tc.expected, err)
})
}
}