-
Notifications
You must be signed in to change notification settings - Fork 1
/
tfe_api_test.go
55 lines (46 loc) · 1.42 KB
/
tfe_api_test.go
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
package concourse_tfe_resource
import (
"fmt"
"github.com/hashicorp/go-tfe"
"go.uber.org/mock/gomock"
"strings"
"testing"
)
func TestGetWorkspaceOutputs(t *testing.T) {
t.Run("error getting workspace state version", func(t *testing.T) {
setup(t)
stateVersions.EXPECT().ReadCurrentWithOptions(gomock.Any(), "foo", gomock.Any()).Return(nil, fmt.Errorf("NO"))
result, err := getWorkspaceOutputs()
if result != nil || err == nil || !strings.Contains(err.Error(), "getting current workspace state") {
t.Errorf("didn't error about workspace state: %v %v", result, err)
}
})
}
func TestNeedsConfirmation(t *testing.T) {
run := setup(t)
run.Actions.IsConfirmable = true
run.HasChanges = true
run.Status = tfe.RunPlanned
if !needsConfirmation(&run) {
t.Error("run in planned with no cost estimation or policy returned false")
}
workspace.Organization.CostEstimationEnabled = true
if needsConfirmation(&run) {
t.Error("run in planned with cost estimates returned true")
}
run.Status = tfe.RunCostEstimated
if !needsConfirmation(&run) {
t.Error("run in cost_estimated with cost estimates returned false")
}
run.PolicyChecks = []*tfe.PolicyCheck{
{}, {},
}
run.Status = tfe.RunPlanned
if needsConfirmation(&run) {
t.Error("run in planned with policy checks returned true")
}
run.Status = tfe.RunPolicyChecked
if !needsConfirmation(&run) {
t.Error("run in policy_checked with policy checks returned false")
}
}