dependabot-nuget 0.316.0 → 0.318.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyInfo.cs +3 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +30 -1
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +25 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Condition.cs +13 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +29 -18
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +7 -9
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +6 -1
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +13 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +18 -10
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +11 -16
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +4 -2
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +29 -13
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +25 -7
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +15 -8
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SpecialImportsConditionPatcher.cs +15 -2
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +11 -3
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +39 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/FrameworkCompatibilityServiceFacts.cs +8 -11
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +108 -15
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +39 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +2 -2
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +291 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandlerTests.cs +311 -6
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandlerTests.cs +273 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandlerTests.cs +307 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +51 -1
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/SpecialFilePatcherTests.cs +25 -0
  29. metadata +4 -4
@@ -633,4 +633,295 @@ public class GroupUpdateAllVersionsHandlerTests : UpdateHandlersTestsBase
633
633
  ]
634
634
  );
635
635
  }
636
+
637
+ [Fact]
638
+ public async Task GeneratesCreatePullRequest_Grouped_ExistingPrSkipped()
639
+ {
640
+ // two groups specified, but one has existing PR and is skipped
641
+ await TestAsync(
642
+ job: new Job()
643
+ {
644
+ Source = CreateJobSource("/src"),
645
+ DependencyGroups = [
646
+ new()
647
+ {
648
+ Name = "test-group-1",
649
+ Rules = new()
650
+ {
651
+ ["patterns"] = new[] { "Package.For.Group.One" },
652
+ },
653
+ },
654
+ new()
655
+ {
656
+ Name = "test-group-2", // this group has an existing PR and will be skipped
657
+ Rules = new()
658
+ {
659
+ ["patterns"] = new[] { "Package.For.Group.Two" },
660
+ },
661
+ },
662
+ ],
663
+ ExistingGroupPullRequests = [
664
+ new()
665
+ {
666
+ DependencyGroupName = "test-group-2",
667
+ Dependencies = [
668
+ new()
669
+ {
670
+ DependencyName = "Package.For.Group.Two",
671
+ DependencyVersion = NuGetVersion.Parse("2.0.1"),
672
+ }
673
+ ]
674
+ }
675
+ ]
676
+ },
677
+ files: [
678
+ ("src/project.csproj", "initial contents"),
679
+ ],
680
+ discoveryWorker: TestDiscoveryWorker.FromResults(
681
+ ("/src", new WorkspaceDiscoveryResult()
682
+ {
683
+ Path = "/src",
684
+ Projects = [
685
+ new()
686
+ {
687
+ FilePath = "project.csproj",
688
+ Dependencies = [
689
+ new("Package.For.Group.One", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
690
+ new("Package.For.Group.Two", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
691
+ ],
692
+ ImportedFiles = [],
693
+ AdditionalFiles = [],
694
+ }
695
+ ],
696
+ })
697
+ ),
698
+ analyzeWorker: new TestAnalyzeWorker(input =>
699
+ {
700
+ var repoRoot = input.Item1;
701
+ var discovery = input.Item2;
702
+ var dependencyInfo = input.Item3;
703
+ var newVersion = dependencyInfo.Name switch
704
+ {
705
+ "Package.For.Group.One" => "1.0.1",
706
+ "Package.For.Group.Two" => "2.0.1",
707
+ _ => throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}"),
708
+ };
709
+ return Task.FromResult(new AnalysisResult()
710
+ {
711
+ CanUpdate = true,
712
+ UpdatedVersion = newVersion,
713
+ UpdatedDependencies = [],
714
+ });
715
+ }),
716
+ updaterWorker: new TestUpdaterWorker(async input =>
717
+ {
718
+ var repoRoot = input.Item1;
719
+ var workspacePath = input.Item2;
720
+ var dependencyName = input.Item3;
721
+ var previousVersion = input.Item4;
722
+ var newVersion = input.Item5;
723
+ var isTransitive = input.Item6;
724
+
725
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), $"updated contents for {dependencyName}/{newVersion}");
726
+
727
+ return new UpdateOperationResult()
728
+ {
729
+ UpdateOperations = [new DirectUpdate() { DependencyName = dependencyName, NewVersion = NuGetVersion.Parse(newVersion), UpdatedFiles = [workspacePath] }],
730
+ };
731
+ }),
732
+ expectedUpdateHandler: GroupUpdateAllVersionsHandler.Instance,
733
+ expectedApiMessages: [
734
+ new IncrementMetric()
735
+ {
736
+ Metric = "updater.started",
737
+ Tags = new()
738
+ {
739
+ ["operation"] = "group_update_all_versions",
740
+ }
741
+ },
742
+ new UpdatedDependencyList()
743
+ {
744
+ Dependencies = [
745
+ new()
746
+ {
747
+ Name = "Package.For.Group.One",
748
+ Version = "1.0.0",
749
+ Requirements = [
750
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
751
+ ],
752
+ },
753
+ new()
754
+ {
755
+ Name = "Package.For.Group.Two",
756
+ Version = "2.0.0",
757
+ Requirements = [
758
+ new() { Requirement = "2.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
759
+ ],
760
+ },
761
+ ],
762
+ DependencyFiles = ["/src/project.csproj"],
763
+ },
764
+ new CreatePullRequest()
765
+ {
766
+ Dependencies = [
767
+ new()
768
+ {
769
+ Name = "Package.For.Group.One",
770
+ Version = "1.0.1",
771
+ Requirements = [
772
+ new() { Requirement = "1.0.1", File = "/src/project.csproj", Groups = ["dependencies"], Source = new() { SourceUrl = null } },
773
+ ],
774
+ PreviousVersion = "1.0.0",
775
+ PreviousRequirements = [
776
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
777
+ ],
778
+ },
779
+ ],
780
+ UpdatedDependencyFiles = [
781
+ new()
782
+ {
783
+ Directory = "/src",
784
+ Name = "project.csproj",
785
+ Content = "updated contents for Package.For.Group.One/1.0.1",
786
+ },
787
+ ],
788
+ BaseCommitSha = "TEST-COMMIT-SHA",
789
+ CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
790
+ PrTitle = RunWorkerTests.TestPullRequestTitle,
791
+ PrBody = RunWorkerTests.TestPullRequestBody,
792
+ DependencyGroup = "test-group-1",
793
+ },
794
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
795
+ ]
796
+ );
797
+ }
798
+
799
+ [Fact]
800
+ public async Task IgnoredVersionUpdateTypesAreHonored()
801
+ {
802
+ await TestAsync(
803
+ job: new()
804
+ {
805
+ Source = CreateJobSource("/src"),
806
+ IgnoreConditions = [
807
+ new Condition()
808
+ {
809
+ DependencyName = "Some.Dependency",
810
+ UpdateTypes = [ConditionUpdateType.SemVerMajor],
811
+ }
812
+ ]
813
+ },
814
+ files: [("src/project.csproj", "initial contents")],
815
+ discoveryWorker: TestDiscoveryWorker.FromResults(
816
+ ("/src", new WorkspaceDiscoveryResult()
817
+ {
818
+ Path = "/src",
819
+ Projects = [
820
+ new()
821
+ {
822
+ FilePath = "project.csproj",
823
+ Dependencies = [
824
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
825
+ ],
826
+ ImportedFiles = [],
827
+ AdditionalFiles = [],
828
+ }
829
+ ],
830
+ })
831
+ ),
832
+ analyzeWorker: new TestAnalyzeWorker(input =>
833
+ {
834
+ var repoRoot = input.Item1;
835
+ var discovery = input.Item2;
836
+ var dependencyInfo = input.Item3;
837
+ if (dependencyInfo.IgnoredUpdateTypes.Length != 1 || !dependencyInfo.IgnoredUpdateTypes.Contains(ConditionUpdateType.SemVerMajor))
838
+ {
839
+ throw new InvalidOperationException($"Expected to see ignored update type of {nameof(ConditionUpdateType.SemVerMajor)} but found [{string.Join(", ", dependencyInfo.IgnoredUpdateTypes)}]");
840
+ }
841
+ var newVersion = dependencyInfo.Name switch
842
+ {
843
+ "Some.Dependency" => "1.1.0",
844
+ _ => throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}"),
845
+ };
846
+ return Task.FromResult(new AnalysisResult()
847
+ {
848
+ CanUpdate = true,
849
+ UpdatedVersion = newVersion,
850
+ UpdatedDependencies = [],
851
+ });
852
+ }),
853
+ updaterWorker: new TestUpdaterWorker(async input =>
854
+ {
855
+ var repoRoot = input.Item1;
856
+ var workspacePath = input.Item2;
857
+ var dependencyName = input.Item3;
858
+ var previousVersion = input.Item4;
859
+ var newVersion = input.Item5;
860
+ var isTransitive = input.Item6;
861
+
862
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
863
+
864
+ return new UpdateOperationResult()
865
+ {
866
+ UpdateOperations = [new DirectUpdate() { DependencyName = dependencyName, NewVersion = NuGetVersion.Parse(newVersion), UpdatedFiles = [workspacePath] }],
867
+ };
868
+ }),
869
+ expectedUpdateHandler: GroupUpdateAllVersionsHandler.Instance,
870
+ expectedApiMessages: [
871
+ new IncrementMetric()
872
+ {
873
+ Metric = "updater.started",
874
+ Tags = new()
875
+ {
876
+ ["operation"] = "group_update_all_versions",
877
+ }
878
+ },
879
+ new UpdatedDependencyList()
880
+ {
881
+ Dependencies = [
882
+ new()
883
+ {
884
+ Name = "Some.Dependency",
885
+ Version = "1.0.0",
886
+ Requirements = [
887
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
888
+ ],
889
+ },
890
+ ],
891
+ DependencyFiles = ["/src/project.csproj"],
892
+ },
893
+ new CreatePullRequest()
894
+ {
895
+ Dependencies = [
896
+ new()
897
+ {
898
+ Name = "Some.Dependency",
899
+ Version = "1.1.0",
900
+ Requirements = [
901
+ new() { Requirement = "1.1.0", File = "/src/project.csproj", Groups = ["dependencies"], Source = new() { SourceUrl = null } },
902
+ ],
903
+ PreviousVersion = "1.0.0",
904
+ PreviousRequirements = [
905
+ new() { Requirement = "1.0.0", File = "/src/project.csproj", Groups = ["dependencies"] },
906
+ ],
907
+ },
908
+ ],
909
+ UpdatedDependencyFiles = [
910
+ new()
911
+ {
912
+ Directory = "/src",
913
+ Name = "project.csproj",
914
+ Content = "updated contents",
915
+ },
916
+ ],
917
+ BaseCommitSha = "TEST-COMMIT-SHA",
918
+ CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
919
+ PrTitle = RunWorkerTests.TestPullRequestTitle,
920
+ PrBody = RunWorkerTests.TestPullRequestBody,
921
+ DependencyGroup = null,
922
+ },
923
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
924
+ ]
925
+ );
926
+ }
636
927
  }
@@ -1,3 +1,5 @@
1
+ using System.Collections.Immutable;
2
+
1
3
  using NuGet.Versioning;
2
4
 
3
5
  using NuGetUpdater.Core.Analyze;
@@ -12,12 +14,6 @@ namespace NuGetUpdater.Core.Test.Run.UpdateHandlers;
12
14
 
13
15
  public class RefreshGroupUpdatePullRequestHandlerTests : UpdateHandlersTestsBase
14
16
  {
15
- // group name must match, existing pr must be found
16
- // if updated_deps is empty, close(update_no_longer_possible)
17
- // if updated_deps is different, close(dependencies_changed), create()
18
- // else if perfect match, update()
19
- // else create()
20
-
21
17
  [Fact]
22
18
  public async Task GeneratesUpdatePullRequest()
23
19
  {
@@ -139,6 +135,315 @@ public class RefreshGroupUpdatePullRequestHandlerTests : UpdateHandlersTestsBase
139
135
  );
140
136
  }
141
137
 
138
+ [Fact]
139
+ public async Task GeneratesUpdatePullRequest_FirstUpdateDidNothingSecondUpdateSucceeded()
140
+ {
141
+ await TestAsync(
142
+ job: new Job()
143
+ {
144
+ Dependencies = ["Some.Dependency"],
145
+ DependencyGroups = [new() { Name = "test_group" }],
146
+ DependencyGroupToRefresh = "test_group",
147
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
148
+ Source = CreateJobSource("/src"),
149
+ UpdatingAPullRequest = true,
150
+ },
151
+ files: [
152
+ ("src/project1.csproj", "initial contents"),
153
+ ("src/project2.csproj", "initial contents"),
154
+ ],
155
+ discoveryWorker: TestDiscoveryWorker.FromResults(
156
+ ("/src", new WorkspaceDiscoveryResult()
157
+ {
158
+ Path = "/src",
159
+ Projects = [
160
+ new()
161
+ {
162
+ FilePath = "project1.csproj",
163
+ Dependencies = [
164
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
165
+ new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
166
+ ],
167
+ ImportedFiles = [],
168
+ AdditionalFiles = [],
169
+ },
170
+ new()
171
+ {
172
+ FilePath = "project2.csproj",
173
+ Dependencies = [
174
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
175
+ new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
176
+ ],
177
+ ImportedFiles = [],
178
+ AdditionalFiles = [],
179
+ },
180
+ ],
181
+ })
182
+ ),
183
+ analyzeWorker: new TestAnalyzeWorker(input =>
184
+ {
185
+ var repoRoot = input.Item1;
186
+ var discovery = input.Item2;
187
+ var dependencyInfo = input.Item3;
188
+ if (dependencyInfo.Name != "Some.Dependency")
189
+ {
190
+ throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}");
191
+ }
192
+
193
+ return Task.FromResult(new AnalysisResult()
194
+ {
195
+ CanUpdate = true,
196
+ UpdatedVersion = "2.0.0",
197
+ UpdatedDependencies = [],
198
+ });
199
+ }),
200
+ updaterWorker: new TestUpdaterWorker(async input =>
201
+ {
202
+ var repoRoot = input.Item1;
203
+ var workspacePath = input.Item2;
204
+ var dependencyName = input.Item3;
205
+ var previousVersion = input.Item4;
206
+ var newVersion = input.Item5;
207
+ var isTransitive = input.Item6;
208
+
209
+ ImmutableArray<UpdateOperationBase> updateOperations = [];
210
+ if (workspacePath.EndsWith("project2.csproj"))
211
+ {
212
+ // only report an update performed on the second project
213
+ updateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project2.csproj"] }];
214
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
215
+ }
216
+
217
+ return new UpdateOperationResult()
218
+ {
219
+ UpdateOperations = updateOperations,
220
+ };
221
+ }),
222
+ expectedUpdateHandler: RefreshGroupUpdatePullRequestHandler.Instance,
223
+ expectedApiMessages: [
224
+ new UpdatedDependencyList()
225
+ {
226
+ Dependencies = [
227
+ new()
228
+ {
229
+ Name = "Some.Dependency",
230
+ Version = "1.0.0",
231
+ Requirements = [
232
+ new() { Requirement = "1.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
233
+ ],
234
+ },
235
+ new()
236
+ {
237
+ Name = "Unrelated.Dependency",
238
+ Version = "3.0.0",
239
+ Requirements = [
240
+ new() { Requirement = "3.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
241
+ ],
242
+ },
243
+ new()
244
+ {
245
+ Name = "Some.Dependency",
246
+ Version = "1.0.0",
247
+ Requirements = [
248
+ new() { Requirement = "1.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
249
+ ],
250
+ },
251
+ new()
252
+ {
253
+ Name = "Unrelated.Dependency",
254
+ Version = "3.0.0",
255
+ Requirements = [
256
+ new() { Requirement = "3.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
257
+ ],
258
+ },
259
+ ],
260
+ DependencyFiles = ["/src/project1.csproj", "/src/project2.csproj"],
261
+ },
262
+ new IncrementMetric()
263
+ {
264
+ Metric = "updater.started",
265
+ Tags = new()
266
+ {
267
+ ["operation"] = "update_version_group_pr",
268
+ }
269
+ },
270
+ new UpdatePullRequest()
271
+ {
272
+ DependencyNames = ["Some.Dependency"],
273
+ DependencyGroup = "test_group",
274
+ UpdatedDependencyFiles = [
275
+ new()
276
+ {
277
+ Directory = "/src",
278
+ Name = "project2.csproj",
279
+ Content = "updated contents",
280
+ }
281
+ ],
282
+ BaseCommitSha = "TEST-COMMIT-SHA",
283
+ CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
284
+ PrTitle = RunWorkerTests.TestPullRequestTitle,
285
+ PrBody = RunWorkerTests.TestPullRequestBody,
286
+ },
287
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
288
+ ]
289
+ );
290
+ }
291
+
292
+ [Fact]
293
+ public async Task GeneratesUpdatePullRequest_FirstDependencyNotAbleToUpdate()
294
+ {
295
+ var responseNumber = 0; // used to track which request was sent
296
+ await TestAsync(
297
+ job: new Job()
298
+ {
299
+ Dependencies = ["Some.Dependency"],
300
+ DependencyGroups = [new() { Name = "test_group" }],
301
+ DependencyGroupToRefresh = "test_group",
302
+ ExistingPullRequests = [new() { Dependencies = [new() { DependencyName = "Some.Dependency", DependencyVersion = NuGetVersion.Parse("2.0.0") }] }],
303
+ Source = CreateJobSource("/src"),
304
+ UpdatingAPullRequest = true,
305
+ },
306
+ files: [
307
+ ("src/project1.csproj", "initial contents"),
308
+ ("src/project2.csproj", "initial contents"),
309
+ ],
310
+ discoveryWorker: TestDiscoveryWorker.FromResults(
311
+ ("/src", new WorkspaceDiscoveryResult()
312
+ {
313
+ Path = "/src",
314
+ Projects = [
315
+ new()
316
+ {
317
+ FilePath = "project1.csproj",
318
+ Dependencies = [
319
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
320
+ new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
321
+ ],
322
+ ImportedFiles = [],
323
+ AdditionalFiles = [],
324
+ },
325
+ new()
326
+ {
327
+ FilePath = "project2.csproj",
328
+ Dependencies = [
329
+ new("Some.Dependency", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
330
+ new("Unrelated.Dependency", "3.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
331
+ ],
332
+ ImportedFiles = [],
333
+ AdditionalFiles = [],
334
+ },
335
+ ],
336
+ })
337
+ ),
338
+ analyzeWorker: new TestAnalyzeWorker(input =>
339
+ {
340
+ var repoRoot = input.Item1;
341
+ var discovery = input.Item2;
342
+ var dependencyInfo = input.Item3;
343
+ if (dependencyInfo.Name != "Some.Dependency")
344
+ {
345
+ throw new NotImplementedException($"Test didn't expect to update dependency {dependencyInfo.Name}");
346
+ }
347
+
348
+ AnalysisResult result = responseNumber == 0
349
+ ? new() { CanUpdate = false, UpdatedVersion = "1.0.0", UpdatedDependencies = [] }
350
+ : new() { CanUpdate = true, UpdatedVersion = "2.0.0", UpdatedDependencies = [] };
351
+ responseNumber++;
352
+
353
+ return Task.FromResult(result);
354
+ }),
355
+ updaterWorker: new TestUpdaterWorker(async input =>
356
+ {
357
+ var repoRoot = input.Item1;
358
+ var workspacePath = input.Item2;
359
+ var dependencyName = input.Item3;
360
+ var previousVersion = input.Item4;
361
+ var newVersion = input.Item5;
362
+ var isTransitive = input.Item6;
363
+
364
+ ImmutableArray<UpdateOperationBase> updateOperations = [];
365
+ if (workspacePath.EndsWith("project2.csproj"))
366
+ {
367
+ // only report an update performed on the second project
368
+ updateOperations = [new DirectUpdate() { DependencyName = "Some.Dependency", NewVersion = NuGetVersion.Parse("2.0.0"), UpdatedFiles = ["/src/project2.csproj"] }];
369
+ await File.WriteAllTextAsync(Path.Join(repoRoot, workspacePath), "updated contents");
370
+ }
371
+
372
+ return new UpdateOperationResult()
373
+ {
374
+ UpdateOperations = updateOperations,
375
+ };
376
+ }),
377
+ expectedUpdateHandler: RefreshGroupUpdatePullRequestHandler.Instance,
378
+ expectedApiMessages: [
379
+ new UpdatedDependencyList()
380
+ {
381
+ Dependencies = [
382
+ new()
383
+ {
384
+ Name = "Some.Dependency",
385
+ Version = "1.0.0",
386
+ Requirements = [
387
+ new() { Requirement = "1.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
388
+ ],
389
+ },
390
+ new()
391
+ {
392
+ Name = "Unrelated.Dependency",
393
+ Version = "3.0.0",
394
+ Requirements = [
395
+ new() { Requirement = "3.0.0", File = "/src/project1.csproj", Groups = ["dependencies"] },
396
+ ],
397
+ },
398
+ new()
399
+ {
400
+ Name = "Some.Dependency",
401
+ Version = "1.0.0",
402
+ Requirements = [
403
+ new() { Requirement = "1.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
404
+ ],
405
+ },
406
+ new()
407
+ {
408
+ Name = "Unrelated.Dependency",
409
+ Version = "3.0.0",
410
+ Requirements = [
411
+ new() { Requirement = "3.0.0", File = "/src/project2.csproj", Groups = ["dependencies"] },
412
+ ],
413
+ },
414
+ ],
415
+ DependencyFiles = ["/src/project1.csproj", "/src/project2.csproj"],
416
+ },
417
+ new IncrementMetric()
418
+ {
419
+ Metric = "updater.started",
420
+ Tags = new()
421
+ {
422
+ ["operation"] = "update_version_group_pr",
423
+ }
424
+ },
425
+ new UpdatePullRequest()
426
+ {
427
+ DependencyNames = ["Some.Dependency"],
428
+ DependencyGroup = "test_group",
429
+ UpdatedDependencyFiles = [
430
+ new()
431
+ {
432
+ Directory = "/src",
433
+ Name = "project2.csproj",
434
+ Content = "updated contents",
435
+ }
436
+ ],
437
+ BaseCommitSha = "TEST-COMMIT-SHA",
438
+ CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
439
+ PrTitle = RunWorkerTests.TestPullRequestTitle,
440
+ PrBody = RunWorkerTests.TestPullRequestBody,
441
+ },
442
+ new MarkAsProcessed("TEST-COMMIT-SHA"),
443
+ ]
444
+ );
445
+ }
446
+
142
447
  [Fact]
143
448
  public async Task GeneratesClosePullRequest_UpdateNoLongerPossible()
144
449
  {