From 83fd7861f03d40f8d07859d68ceb7681b8f4ed9c Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Wed, 4 Sep 2024 11:07:36 +0800 Subject: [PATCH] Do not reuse test subject for workspace run task 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. --- .../resource_tfe_workspace_run_task_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/provider/resource_tfe_workspace_run_task_test.go b/internal/provider/resource_tfe_workspace_run_task_test.go index 737256ee8..67e498a1a 100644 --- a/internal/provider/resource_tfe_workspace_run_task_test.go +++ b/internal/provider/resource_tfe_workspace_run_task_test.go @@ -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 @@ -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)