Skip to content

Commit

Permalink
Fix Experiments evaluation of new dep dependencies (#1315)
Browse files Browse the repository at this point in the history
* Fix Experiments evaluation of new dep dependencies
  • Loading branch information
grvillic authored Dec 2, 2024
1 parent 952c1ce commit 218b693
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ public ExperimentDiff(
var experimentDetectorList = new List<ExperimentDetector>();

// Need performance benchmark to see if this is worth parallelization
foreach (var id in newComponentDictionary.Keys.Intersect(oldComponentDictionary.Keys))
foreach (var newComponentPair in newComponentDictionary)
{
var oldComponent = oldComponentDictionary[id];
var newComponent = newComponentDictionary[id];
var newComponent = newComponentPair.Value;
var id = newComponentPair.Key;

if (!oldComponentDictionary.TryGetValue(id, out var oldComponent))
{
if (newComponent.DevelopmentDependency)
{
developmentDependencyChanges.Add(new DevelopmentDependencyChange(
id,
oldValue: false,
newValue: newComponent.DevelopmentDependency));
}

continue;
}

if (oldComponent.DevelopmentDependency != newComponent.DevelopmentDependency)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,27 @@ public void ExperimentDiff_MultipleIds_ShouldntThrow()

action.Should().NotThrow();
}

[TestMethod]
public void ExperimentDiff_DiffsAddedDevDependenciesMissingInControlGroup()
{
var componentA = ExperimentTestUtils.CreateRandomScannedComponent();
componentA.IsDevelopmentDependency = true;

var diff = new ExperimentDiff(
[],
[new ExperimentComponent(componentA)]);

diff.DevelopmentDependencyChanges.Should().ContainSingle();

var change = diff.DevelopmentDependencyChanges.First();
change.Id.Should().Be(componentA.Component.Id);
change.OldValue.Should().BeFalse();
change.NewValue.Should().BeTrue();

diff.AddedIds.Should().BeEquivalentTo([componentA.Component.Id]);
diff.RemovedIds.Should().BeEmpty();
diff.AddedRootIds.Should().BeEmpty();
diff.RemovedRootIds.Should().BeEmpty();
}
}

0 comments on commit 218b693

Please sign in to comment.