-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathadmin_run_test.go
More file actions
65 lines (57 loc) · 1.6 KB
/
admin_run_test.go
File metadata and controls
65 lines (57 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright IBM Corp. 2018, 2025
// SPDX-License-Identifier: MPL-2.0
package tfe
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func Test_validateAdminRunFilterParams(t *testing.T) {
t.Parallel()
// All RunStatus values - keep this in sync with run.go
validRunStatuses := []string{
"applied",
"applying",
"apply_queued",
"canceled",
"confirmed",
"cost_estimated",
"cost_estimating",
"discarded",
"errored",
"fetching",
"fetching_completed",
"pending",
"planned",
"planned_and_finished",
"planned_and_saved",
"planning",
"plan_queued",
"policy_checked",
"policy_checking",
"policy_override",
"policy_soft_failed",
"post_plan_awaiting_decision",
"post_plan_completed",
"post_plan_running",
"pre_apply_running",
"pre_apply_completed",
"pre_plan_completed",
"pre_plan_running",
"queuing",
"queuing_apply",
}
for _, v := range validRunStatuses {
t.Run(v, func(t *testing.T) {
require.NoError(t, validateAdminRunFilterParams(v), fmt.Sprintf("'%s' should be valid", v))
})
}
// empty string is allowed
require.NoError(t, validateAdminRunFilterParams(""), "empty string should be valid")
// comma-separated list, all valid
require.NoError(t, validateAdminRunFilterParams("applied,planned,canceled"), "'applied,planned,canceled' should be valid)")
// invalid values
require.Error(t, validateAdminRunFilterParams("cost_estimate"), "invalid value: cost_estimate")
// comma-separated list, some invalid
require.Error(t, validateAdminRunFilterParams("applied,not-planned,canceled"), "'applied,not-planned,canceled' should be invalid)")
}