From 7374cba6085c8468a1803559830319ff9843b4d9 Mon Sep 17 00:00:00 2001 From: "pavel.butuzov" Date: Sun, 30 Jun 2024 23:38:39 +0300 Subject: [PATCH] Added the "automaticUpdationLinksToTestCases" configuration parameter. --- Tms.Adapter.Core/Client/ITmsClient.cs | 1 + Tms.Adapter.Core/Client/TmsClient.cs | 2 +- Tms.Adapter.Core/Writer/Writer.cs | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Tms.Adapter.Core/Client/ITmsClient.cs b/Tms.Adapter.Core/Client/ITmsClient.cs index aba2b07..75a0b45 100644 --- a/Tms.Adapter.Core/Client/ITmsClient.cs +++ b/Tms.Adapter.Core/Client/ITmsClient.cs @@ -16,4 +16,5 @@ public interface ITmsClient Task UploadAttachment(string fileName, Stream content); Task CreateTestRun(); Task CompleteTestRun(); + Task GetAutotestByExternalId(string externalId); } \ No newline at end of file diff --git a/Tms.Adapter.Core/Client/TmsClient.cs b/Tms.Adapter.Core/Client/TmsClient.cs index 6c8c50e..0c00a33 100644 --- a/Tms.Adapter.Core/Client/TmsClient.cs +++ b/Tms.Adapter.Core/Client/TmsClient.cs @@ -244,7 +244,7 @@ public async Task CompleteTestRun() _logger.LogDebug("Complete test run is successfully"); } - private async Task GetAutotestByExternalId(string externalId) + public async Task GetAutotestByExternalId(string externalId) { _logger.LogDebug("Getting autotest by external id {Id}", externalId); diff --git a/Tms.Adapter.Core/Writer/Writer.cs b/Tms.Adapter.Core/Writer/Writer.cs index 6c792d0..db11e39 100644 --- a/Tms.Adapter.Core/Writer/Writer.cs +++ b/Tms.Adapter.Core/Writer/Writer.cs @@ -60,9 +60,19 @@ public async Task Write(TestContainer result, ClassContainer container) } } - private async Task UpdateTestLinkToWorkItems(string autoTestId, List workItemIds) + private async Task UpdateTestLinkToWorkItems(string externalId, List 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) { @@ -77,10 +87,10 @@ private async Task UpdateTestLinkToWorkItems(string autoTestId, List wor if (_tmsSettings.AutomaticUpdationLinksToTestCases) { - await _client.DeleteAutoTestLinkFromWorkItem(autoTestId, linkedWorkItemId); + await _client.DeleteAutoTestLinkFromWorkItem(autotestId, linkedWorkItemId); } } - await _client.LinkAutoTestToWorkItems(autoTestId, workItemIds); + await _client.LinkAutoTestToWorkItems(autotestId, workItemIds); } } \ No newline at end of file