Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FindTestPlan to actually check the right things #1773

Merged
merged 5 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -622,27 +622,28 @@ private ITestSuiteBase FindSuiteEntry(IStaticTestSuite staticSuite, string title
return testSuit;
MrHinsh marked this conversation as resolved.
Show resolved Hide resolved
}

private ITestPlan FindTestPlan(TestManagementContext tmc, string name)
private ITestPlan FindTestPlan(string planName, int sourcePlanId)
{
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan");
ITestPlan testPlan = (from p in tmc.Project.TestPlans.Query("Select * From TestPlan") where p.Name == name select p).SingleOrDefault();
ITestPlan testPlan = (from p in _targetTestStore.Project.TestPlans.Query("Select * From TestPlan") where p.Name == planName select p).SingleOrDefault();

if (testPlan != null)
{
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: FOUND Test Plan with {name}", name);
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: FOUND Test Plan with {name}", planName);
//Check test plan is in fact the right one
var sourceWI = Engine.Source.WorkItems.GetWorkItem(testPlan.Id.ToString());
var sourceWI = Engine.Source.WorkItems.GetWorkItem(sourcePlanId);
string expectedReflectedId = Engine.Source.WorkItems.CreateReflectedWorkItemId(sourceWI).ToString();
string workItemReflectedId = (string)sourceWI.Fields[Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value;
var targetWI = Engine.Source.WorkItems.GetWorkItem(testPlan.Id.ToString());
MrHinsh marked this conversation as resolved.
Show resolved Hide resolved
string workItemReflectedId = (string)targetWI.Fields[Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value;
if (workItemReflectedId != expectedReflectedId)
{
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: Fouund test plan with name {name} does not match {workItemReflectedId} ", name, workItemReflectedId);
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: Found test plan with name {name} does not match {workItemReflectedId} ", planName, workItemReflectedId);
testPlan = null;
}
}
else
{
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: NOT FOUND Test Plan with {name}", name);
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: NOT FOUND Test Plan with {name}", planName);
}
return testPlan;
}
Expand Down Expand Up @@ -861,7 +862,7 @@ private void ProcessTestPlan(ITestPlan sourcePlan)
? $"{Engine.Source.WorkItems.GetProject().Name}-{sourcePlan.Name}"
: $"{sourcePlan.Name}";
InnerLog(sourcePlan, $"Process Plan {newPlanName}", 0, true);
var targetPlan = FindTestPlan(_targetTestStore, newPlanName);
var targetPlan = FindTestPlan(newPlanName, sourcePlan.Id);
//if (targetPlan != null && TargetPlanContansTag(targetPlan.Id))
//{
// return;
Expand Down Expand Up @@ -921,7 +922,7 @@ private void ProcessTestPlan(ITestPlan sourcePlan)
targetPlan.Save();
// Load the plan again, because somehow it doesn't let me set configurations on the already loaded plan
InnerLog(sourcePlan, $"ApplyConfigurationsAndAssignTesters {targetPlan.Name}", 5); ;
ITestPlan targetPlan2 = FindTestPlan(_targetTestStore, targetPlan.Name);
ITestPlan targetPlan2 = FindTestPlan(targetPlan.Name, sourcePlan.Id);
if (targetPlan2 != null)
{
ApplyConfigurationsAndAssignTesters(sourcePlan.RootSuite, targetPlan2.RootSuite);
Expand Down