-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon_test.go
59 lines (52 loc) · 1.51 KB
/
common_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
56
57
58
59
package concourse_tfe_resource
import (
"concourse-tfe-resource/mock-go-tfe"
"github.com/hashicorp/go-tfe"
"go.uber.org/mock/gomock"
"strings"
"testing"
"time"
)
var (
ctrl *gomock.Controller
mockClient tfe.Client
runs *mock_go_tfe.MockRuns
workspaces *mock_go_tfe.MockWorkspaces
variables *mock_go_tfe.MockVariables
stateVersions *mock_go_tfe.MockStateVersions
test *testing.T
)
func setup(t *testing.T) tfe.Run {
test = t
ctrl = gomock.NewController(t)
mockClient = tfe.Client{}
client = &mockClient
runs = mock_go_tfe.NewMockRuns(ctrl)
client.Runs = runs
workspaces = mock_go_tfe.NewMockWorkspaces(ctrl)
client.Workspaces = workspaces
variables = mock_go_tfe.NewMockVariables(ctrl)
client.Variables = variables
stateVersions = mock_go_tfe.NewMockStateVersions(ctrl)
client.StateVersions = stateVersions
workspace = &tfe.Workspace{
ID: "foo",
Organization: &tfe.Organization{CostEstimationEnabled: false},
}
return tfe.Run{
ID: "bar",
Status: tfe.RunPending,
Message: "test run",
CreatedAt: time.Now(),
CostEstimate: &tfe.CostEstimate{
DeltaMonthlyCost: "+a billion dollars",
ProposedMonthlyCost: "a few cents",
},
Actions: &tfe.RunActions{IsConfirmable: true},
ConfigurationVersion: &tfe.ConfigurationVersion{Source: tfe.ConfigurationSourceGithub},
HasChanges: true,
}
}
func didntErrorWithSubstr(err error, expected string) bool {
return err == nil || !strings.Contains(err.Error(), expected)
}