Skip to content

Commit

Permalink
Fixed getting test cases by test suite id.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Butuzov committed Nov 7, 2023
1 parent 331bd76 commit 3899d9b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
16 changes: 14 additions & 2 deletions Migrators/TestLinkExporter/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public TestLinkProject GetProject()
throw new Exception($"Project {_projectName} is not found");
}

_logger.LogDebug("Received project by name {ProjectName}: {@Project}", _projectName, project);

return new TestLinkProject
{
Id = project.id,
Expand All @@ -73,6 +75,8 @@ public List<TestLinkSuite> GetSuitesByProjectId(int id)
throw new Exception($"Test suites from {_projectName} is not found");
}

_logger.LogDebug("Received test suites by id {Id}: {@TestSuites}", id, testSuites);

foreach ( var suite in testSuites) {
suites.Add(new TestLinkSuite
{
Expand All @@ -91,6 +95,8 @@ public List<TestLinkSuite> GetSharedSuitesBySuiteId(int id)

var testSuites = _client.GetTestSuitesForTestSuite(id);

_logger.LogDebug("Received shared test suites by test suite id {Id}: {@TestSuites}", id, testSuites);

foreach (var suite in testSuites)
{
suites.Add(new TestLinkSuite
Expand All @@ -106,9 +112,11 @@ public List<TestLinkSuite> GetSharedSuitesBySuiteId(int id)

public List<int> GetTestCaseIdsBySuiteId(int id)
{
var testCaseIds = new List<TestLinkTestCase>();
var testCaseIds = _client.GetTestCaseIdsForTestSuite(id, false);

return _client.GetTestCaseIdsForTestSuite(2, true);
_logger.LogDebug("Received test case ids by test suite id {Id}: {@TestCaseIds}", id, testCaseIds);

return testCaseIds;
}

public TestLinkTestCase GetTestCaseById(int id)
Expand All @@ -122,6 +130,8 @@ public TestLinkTestCase GetTestCaseById(int id)
throw new Exception($"Test case with id {id} is not found");
}

_logger.LogDebug("Received test case by id {Id}: {@TestCase}", id, testCase);

return new TestLinkTestCase
{
Id = id,
Expand Down Expand Up @@ -151,6 +161,8 @@ public List<TestLinkAttachment> GetAttachmentsByTestCaseId(int id)
{
var attachments = _client.GetTestCaseAttachments(id);

_logger.LogDebug("Received attachments by test case id {Id}: {@Attachments}", id, attachments);

return attachments.Select(attachment =>
new TestLinkAttachment
{
Expand Down
3 changes: 1 addition & 2 deletions Migrators/TestLinkExporter/Services/AttachmentService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using TestLinkExporter.Models;
using JsonWriter;
using Microsoft.Extensions.Logging;
using TestLinkExporter.Client;
Expand All @@ -20,7 +19,7 @@ public AttachmentService(ILogger<AttachmentService> logger, IClient client, IWri

public async Task<List<string>> DownloadAttachments(int id, Guid workItemId)
{
_logger.LogInformation("Downloading attachment: {Id}", id);
_logger.LogInformation("Getting attachments by test case id: {Id}", id);

var attachments = _client.GetAttachmentsByTestCaseId(id);

Expand Down
3 changes: 1 addition & 2 deletions Migrators/TestLinkExporter/Services/TestCaseService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Models;
using System;
using System.Text.RegularExpressions;
using TestLinkExporter.Client;
using TestLinkExporter.Models;
Expand Down Expand Up @@ -82,7 +81,7 @@ private static PriorityType ConvertPriority(int priority)
3 => PriorityType.High,
2 => PriorityType.Medium,
1 => PriorityType.Low,
_ => throw new Exception($"Failed to convert priority {priority}")
_ => PriorityType.Medium
};
}

Expand Down

0 comments on commit 3899d9b

Please sign in to comment.