Skip to content

Commit

Permalink
Do not reuse test subject for workspace run task
Browse files Browse the repository at this point in the history
Previously the test subject for the stagesSupport unit tests would reuse the
subject and resolver however this led to timing issues when parallel tests
were run. This commit changes the test to create new objects per test.
  • Loading branch information
glennsarti committed Sep 4, 2024
1 parent a2f51f1 commit 692eb6b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/provider/resource_tfe_workspace_run_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import (
)

func TestTFEWorkspaceRunTask_stagesSupport(t *testing.T) {
resolver := &staticCapabilityResolver{}

subject := resourceWorkspaceRunTask{
config: ConfiguredClient{Organization: "Mock", Client: &tfe.Client{}},
capabilities: resolver,
}

testCases := map[string]struct {
isCloud bool
tfeVer string
Expand All @@ -36,9 +29,15 @@ func TestTFEWorkspaceRunTask_stagesSupport(t *testing.T) {

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
resolver := &staticCapabilityResolver{}
resolver.SetIsCloud(testCase.isCloud)
resolver.SetRemoteTFEVersion(testCase.tfeVer)

subject := resourceWorkspaceRunTask{
config: ConfiguredClient{Organization: "Mock", Client: &tfe.Client{}},
capabilities: resolver,
}

actual := subject.supportsStagesProperty()
if actual != testCase.expectResult {
t.Fatalf("expected supportsStagesProperty to be %t, got %t", testCase.expectResult, actual)
Expand Down

0 comments on commit 692eb6b

Please sign in to comment.