Skip to content

Commit

Permalink
Added the "automaticUpdationLinksToTestCases" configuration parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel.butuzov committed Jun 30, 2024
1 parent ffea863 commit 7374cba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions Tms.Adapter.Core/Client/ITmsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public interface ITmsClient
Task<string> UploadAttachment(string fileName, Stream content);
Task CreateTestRun();
Task CompleteTestRun();
Task<AutoTestModel?> GetAutotestByExternalId(string externalId);
}
2 changes: 1 addition & 1 deletion Tms.Adapter.Core/Client/TmsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public async Task CompleteTestRun()
_logger.LogDebug("Complete test run is successfully");
}

private async Task<AutoTestModel?> GetAutotestByExternalId(string externalId)
public async Task<AutoTestModel?> GetAutotestByExternalId(string externalId)
{
_logger.LogDebug("Getting autotest by external id {Id}", externalId);

Expand Down
18 changes: 14 additions & 4 deletions Tms.Adapter.Core/Writer/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,19 @@ public async Task Write(TestContainer result, ClassContainer container)
}
}

private async Task UpdateTestLinkToWorkItems(string autoTestId, List<string> workItemIds)
private async Task UpdateTestLinkToWorkItems(string externalId, List<string> workItemIds)
{
var linkedWorkItems = await _client.GetWorkItemsLinkedToAutoTest(autoTestId);
var autotest = await _client.GetAutotestByExternalId(externalId);

if (autotest == null)
{
_logger.LogError("Autotest with {ID} not found", externalId);
return;
}

var autotestId = autotest.Id.ToString();

var linkedWorkItems = await _client.GetWorkItemsLinkedToAutoTest(autotestId);

foreach (var linkedWorkItem in linkedWorkItems)
{
Expand All @@ -77,10 +87,10 @@ private async Task UpdateTestLinkToWorkItems(string autoTestId, List<string> wor

if (_tmsSettings.AutomaticUpdationLinksToTestCases)
{
await _client.DeleteAutoTestLinkFromWorkItem(autoTestId, linkedWorkItemId);
await _client.DeleteAutoTestLinkFromWorkItem(autotestId, linkedWorkItemId);
}
}

await _client.LinkAutoTestToWorkItems(autoTestId, workItemIds);
await _client.LinkAutoTestToWorkItems(autotestId, workItemIds);
}
}

0 comments on commit 7374cba

Please sign in to comment.