dependabot-nuget 0.283.0 → 0.285.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.Cli/Commands/CloneCommand.cs +40 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +1 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +0 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +144 -0
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/IGitCommandHandler.cs +6 -0
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +37 -0
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyFileNotFound.cs +5 -1
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +9 -2
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobRepoNotFound.cs +13 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobSource.cs +2 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/MarkAsProcessed.cs +6 -1
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceAuthenticationFailure.cs +5 -1
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UnknownError.cs +5 -1
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdateNotPossible.cs +5 -1
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +8 -2
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +73 -31
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +30 -9
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +3 -3
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +2 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +183 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/TestGitCommandHandler.cs +16 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +640 -17
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +10 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +53 -6
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +225 -0
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +106 -0
  29. metadata +13 -5
@@ -26,7 +26,6 @@ public class RunWorkerTests
26
26
  ],
27
27
  job: new Job()
28
28
  {
29
- PackageManager = "nuget",
30
29
  Source = new()
31
30
  {
32
31
  Provider = "github",
@@ -143,7 +142,7 @@ public class RunWorkerTests
143
142
  new DependencyFile()
144
143
  {
145
144
  Name = "project.csproj",
146
- Directory = "some-dir",
145
+ Directory = "/some-dir",
147
146
  Content = """
148
147
  <Project Sdk="Microsoft.NET.Sdk">
149
148
  <PropertyGroup>
@@ -161,10 +160,7 @@ public class RunWorkerTests
161
160
  PrTitle = "TODO: title",
162
161
  PrBody = "TODO: body",
163
162
  },
164
- new MarkAsProcessed()
165
- {
166
- BaseCommitSha = "TEST-COMMIT-SHA",
167
- }
163
+ new MarkAsProcessed("TEST-COMMIT-SHA")
168
164
  ]
169
165
  );
170
166
  }
@@ -209,7 +205,6 @@ public class RunWorkerTests
209
205
  ],
210
206
  job: new Job()
211
207
  {
212
- PackageManager = "nuget",
213
208
  Source = new()
214
209
  {
215
210
  Provider = "github",
@@ -249,26 +244,654 @@ public class RunWorkerTests
249
244
  },
250
245
  expectedApiMessages:
251
246
  [
252
- new PrivateSourceAuthenticationFailure()
247
+ new PrivateSourceAuthenticationFailure([$"{http.BaseUrl.TrimEnd('/')}/index.json"]),
248
+ new MarkAsProcessed("TEST-COMMIT-SHA")
249
+ ]
250
+ );
251
+ }
252
+
253
+ [Fact]
254
+ public async Task UpdateHandlesPackagesConfigFiles()
255
+ {
256
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
257
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
258
+ await RunAsync(
259
+ packages:
260
+ [
261
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
262
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repoMetadata]),
263
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.0", "net8.0", additionalMetadata: [repoMetadata2]),
264
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.1", "net8.0", additionalMetadata: [repoMetadata2]),
265
+ ],
266
+ job: new Job()
267
+ {
268
+ PackageManager = "nuget",
269
+ Source = new()
253
270
  {
254
- Details = $"({http.BaseUrl.TrimEnd('/')}/index.json)"
271
+ Provider = "github",
272
+ Repo = "test/repo",
273
+ Directory = "some-dir",
255
274
  },
256
- new MarkAsProcessed()
275
+ AllowedUpdates =
276
+ [
277
+ new() { UpdateType = "all" }
278
+ ]
279
+ },
280
+ files:
281
+ [
282
+ ("some-dir/project.csproj", """
283
+ <Project Sdk="Microsoft.NET.Sdk">
284
+ <PropertyGroup>
285
+ <TargetFramework>net8.0</TargetFramework>
286
+ </PropertyGroup>
287
+ <ItemGroup>
288
+ <PackageReference Include="Some.Package" Version="1.0.0" />
289
+ </ItemGroup>
290
+ </Project>
291
+ """),
292
+ ("some-dir/packages.config", """
293
+ <?xml version="1.0" encoding="utf-8"?>
294
+ <packages>
295
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
296
+ </packages>
297
+ """),
298
+ ],
299
+ expectedResult: new RunResult()
300
+ {
301
+ Base64DependencyFiles =
302
+ [
303
+ new DependencyFile()
304
+ {
305
+ Directory = "/some-dir",
306
+ Name = "project.csproj",
307
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
308
+ <Project Sdk="Microsoft.NET.Sdk">
309
+ <PropertyGroup>
310
+ <TargetFramework>net8.0</TargetFramework>
311
+ </PropertyGroup>
312
+ <ItemGroup>
313
+ <PackageReference Include="Some.Package" Version="1.0.0" />
314
+ </ItemGroup>
315
+ </Project>
316
+ """))
317
+ },
318
+ new DependencyFile()
319
+ {
320
+ Directory = "/some-dir",
321
+ Name = "packages.config",
322
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
323
+ <?xml version="1.0" encoding="utf-8"?>
324
+ <packages>
325
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
326
+ </packages>
327
+ """))
328
+ }
329
+ ],
330
+ BaseCommitSha = "TEST-COMMIT-SHA",
331
+ },
332
+ expectedApiMessages:
333
+ [
334
+ new UpdatedDependencyList()
335
+ {
336
+ Dependencies =
337
+ [
338
+ new ReportedDependency()
339
+ {
340
+ Name = "Some.Package",
341
+ Version = "1.0.0",
342
+ Requirements =
343
+ [
344
+ new ReportedRequirement()
345
+ {
346
+ Requirement = "1.0.0",
347
+ File = "/some-dir/project.csproj",
348
+ Groups = ["dependencies"],
349
+ }
350
+ ]
351
+ },
352
+ new ReportedDependency()
353
+ {
354
+ Name = "Some.Package2",
355
+ Version = "2.0.0",
356
+ Requirements =
357
+ [
358
+ new ReportedRequirement()
359
+ {
360
+ Requirement = "2.0.0",
361
+ File = "/some-dir/packages.config",
362
+ Groups = ["dependencies"],
363
+ }
364
+ ]
365
+ }
366
+ ],
367
+ DependencyFiles = ["/some-dir/project.csproj", "/some-dir/packages.config"],
368
+ },
369
+ new IncrementMetric()
257
370
  {
371
+ Metric = "updater.started",
372
+ Tags = new()
373
+ {
374
+ ["operation"] = "group_update_all_versions"
375
+ }
376
+ },
377
+ new CreatePullRequest()
378
+ {
379
+ Dependencies =
380
+ [
381
+ new ReportedDependency()
382
+ {
383
+ Name = "Some.Package",
384
+ Version = "1.0.1",
385
+ Requirements =
386
+ [
387
+ new ReportedRequirement()
388
+ {
389
+ Requirement = "1.0.1",
390
+ File = "/some-dir/project.csproj",
391
+ Groups = ["dependencies"],
392
+ Source = new()
393
+ {
394
+ SourceUrl = "https://nuget.example.com/some-package",
395
+ Type = "nuget_repo",
396
+ }
397
+ }
398
+ ],
399
+ PreviousVersion = "1.0.0",
400
+ PreviousRequirements =
401
+ [
402
+ new ReportedRequirement()
403
+ {
404
+ Requirement = "1.0.0",
405
+ File = "/some-dir/project.csproj",
406
+ Groups = ["dependencies"],
407
+ }
408
+ ],
409
+ },
410
+ new ReportedDependency()
411
+ {
412
+ Name = "Some.Package2",
413
+ Version = "2.0.1",
414
+ Requirements =
415
+ [
416
+ new ReportedRequirement()
417
+ {
418
+ Requirement = "2.0.1",
419
+ File = "/some-dir/packages.config",
420
+ Groups = ["dependencies"],
421
+ Source = new()
422
+ {
423
+ SourceUrl = "https://nuget.example.com/some-package2",
424
+ Type = "nuget_repo",
425
+ }
426
+ }
427
+ ],
428
+ PreviousVersion = "2.0.0",
429
+ PreviousRequirements =
430
+ [
431
+ new ReportedRequirement()
432
+ {
433
+ Requirement = "2.0.0",
434
+ File = "/some-dir/packages.config",
435
+ Groups = ["dependencies"],
436
+ }
437
+ ],
438
+ },
439
+ ],
440
+ UpdatedDependencyFiles =
441
+ [
442
+ new DependencyFile()
443
+ {
444
+ Name = "project.csproj",
445
+ Directory = "/some-dir",
446
+ Content = """
447
+ <Project Sdk="Microsoft.NET.Sdk">
448
+ <PropertyGroup>
449
+ <TargetFramework>net8.0</TargetFramework>
450
+ </PropertyGroup>
451
+ <ItemGroup>
452
+ <PackageReference Include="Some.Package" Version="1.0.1" />
453
+ </ItemGroup>
454
+ <ItemGroup>
455
+ <Reference Include="Some.Package2">
456
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
457
+ <Private>True</Private>
458
+ </Reference>
459
+ </ItemGroup>
460
+ </Project>
461
+ """,
462
+ },
463
+ new DependencyFile()
464
+ {
465
+ Name = "packages.config",
466
+ Directory = "/some-dir",
467
+ Content = """
468
+ <?xml version="1.0" encoding="utf-8"?>
469
+ <packages>
470
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
471
+ </packages>
472
+ """,
473
+ },
474
+ ],
258
475
  BaseCommitSha = "TEST-COMMIT-SHA",
259
- }
476
+ CommitMessage = "TODO: message",
477
+ PrTitle = "TODO: title",
478
+ PrBody = "TODO: body",
479
+ },
480
+ new MarkAsProcessed("TEST-COMMIT-SHA")
481
+ ]
482
+ );
483
+ }
484
+
485
+ [Fact]
486
+ public async Task UpdateHandlesPackagesConfigFromReferencedCsprojFiles()
487
+ {
488
+ var repoMetadata = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package" />""");
489
+ var repoMetadata2 = XElement.Parse("""<repository type="git" url="https://nuget.example.com/some-package2" />""");
490
+ await RunAsync(
491
+ packages:
492
+ [
493
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", additionalMetadata: [repoMetadata]),
494
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net8.0", additionalMetadata: [repoMetadata]),
495
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.0", "net8.0", additionalMetadata: [repoMetadata2]),
496
+ MockNuGetPackage.CreateSimplePackage("Some.Package2", "2.0.1", "net8.0", additionalMetadata: [repoMetadata2]),
497
+ ],
498
+ job: new Job()
499
+ {
500
+ PackageManager = "nuget",
501
+ Source = new()
502
+ {
503
+ Provider = "github",
504
+ Repo = "test/repo",
505
+ Directory = "some-dir/ProjectA",
506
+ },
507
+ AllowedUpdates =
508
+ [
509
+ new() { UpdateType = "all" }
510
+ ]
511
+ },
512
+ files:
513
+ [
514
+ ("some-dir/ProjectA/ProjectA.csproj", """
515
+ <Project Sdk="Microsoft.NET.Sdk">
516
+ <PropertyGroup>
517
+ <TargetFramework>net8.0</TargetFramework>
518
+ </PropertyGroup>
519
+ <ItemGroup>
520
+ <PackageReference Include="Some.Package" Version="1.0.0" />
521
+ </ItemGroup>
522
+ <ItemGroup>
523
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
524
+ </ItemGroup>
525
+ </Project>
526
+ """),
527
+ ("some-dir/ProjectA/packages.config", """
528
+ <?xml version="1.0" encoding="utf-8"?>
529
+ <packages>
530
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
531
+ </packages>
532
+ """),
533
+ ("some-dir/ProjectB/ProjectB.csproj", """
534
+ <Project Sdk="Microsoft.NET.Sdk">
535
+ <PropertyGroup>
536
+ <TargetFramework>net8.0</TargetFramework>
537
+ </PropertyGroup>
538
+ <ItemGroup>
539
+ <PackageReference Include="Some.Package" Version="1.0.0" />
540
+ </ItemGroup>
541
+ </Project>
542
+ """),
543
+ ("some-dir/ProjectB/packages.config", """
544
+ <?xml version="1.0" encoding="utf-8"?>
545
+ <packages>
546
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
547
+ </packages>
548
+ """),
549
+ ],
550
+ expectedResult: new RunResult()
551
+ {
552
+ Base64DependencyFiles =
553
+ [
554
+ new DependencyFile()
555
+ {
556
+ Directory = "/some-dir/ProjectB",
557
+ Name = "ProjectB.csproj",
558
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
559
+ <Project Sdk="Microsoft.NET.Sdk">
560
+ <PropertyGroup>
561
+ <TargetFramework>net8.0</TargetFramework>
562
+ </PropertyGroup>
563
+ <ItemGroup>
564
+ <PackageReference Include="Some.Package" Version="1.0.0" />
565
+ </ItemGroup>
566
+ </Project>
567
+ """))
568
+ },
569
+ new DependencyFile()
570
+ {
571
+ Directory = "/some-dir/ProjectB",
572
+ Name = "packages.config",
573
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
574
+ <?xml version="1.0" encoding="utf-8"?>
575
+ <packages>
576
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
577
+ </packages>
578
+ """))
579
+ },
580
+ new DependencyFile()
581
+ {
582
+ Directory = "/some-dir/ProjectA",
583
+ Name = "ProjectA.csproj",
584
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
585
+ <Project Sdk="Microsoft.NET.Sdk">
586
+ <PropertyGroup>
587
+ <TargetFramework>net8.0</TargetFramework>
588
+ </PropertyGroup>
589
+ <ItemGroup>
590
+ <PackageReference Include="Some.Package" Version="1.0.0" />
591
+ </ItemGroup>
592
+ <ItemGroup>
593
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
594
+ </ItemGroup>
595
+ </Project>
596
+ """))
597
+ },
598
+ new DependencyFile()
599
+ {
600
+ Directory = "/some-dir/ProjectA",
601
+ Name = "packages.config",
602
+ Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
603
+ <?xml version="1.0" encoding="utf-8"?>
604
+ <packages>
605
+ <package id="Some.Package2" version="2.0.0" targetFramework="net8.0" />
606
+ </packages>
607
+ """))
608
+ },
609
+ ],
610
+ BaseCommitSha = "TEST-COMMIT-SHA",
611
+ },
612
+ expectedApiMessages:
613
+ [
614
+ new UpdatedDependencyList()
615
+ {
616
+ Dependencies =
617
+ [
618
+ new ReportedDependency()
619
+ {
620
+ Name = "Some.Package",
621
+ Version = "1.0.0",
622
+ Requirements =
623
+ [
624
+ new ReportedRequirement()
625
+ {
626
+ Requirement = "1.0.0",
627
+ File = "/some-dir/ProjectB/ProjectB.csproj",
628
+ Groups = ["dependencies"],
629
+ }
630
+ ]
631
+ },
632
+ new ReportedDependency()
633
+ {
634
+ Name = "Some.Package2",
635
+ Version = "2.0.0",
636
+ Requirements =
637
+ [
638
+ new ReportedRequirement()
639
+ {
640
+ Requirement = "2.0.0",
641
+ File = "/some-dir/ProjectB/packages.config",
642
+ Groups = ["dependencies"],
643
+ }
644
+ ]
645
+ },
646
+ new ReportedDependency()
647
+ {
648
+ Name = "Some.Package",
649
+ Version = "1.0.0",
650
+ Requirements =
651
+ [
652
+ new ReportedRequirement()
653
+ {
654
+ Requirement = "1.0.0",
655
+ File = "/some-dir/ProjectA/ProjectA.csproj",
656
+ Groups = ["dependencies"],
657
+ }
658
+ ]
659
+ },
660
+ new ReportedDependency()
661
+ {
662
+ Name = "Some.Package2",
663
+ Version = "2.0.0",
664
+ Requirements =
665
+ [
666
+ new ReportedRequirement()
667
+ {
668
+ Requirement = "2.0.0",
669
+ File = "/some-dir/ProjectA/packages.config",
670
+ Groups = ["dependencies"],
671
+ }
672
+ ]
673
+ },
674
+ ],
675
+ DependencyFiles = ["/some-dir/ProjectB/ProjectB.csproj", "/some-dir/ProjectA/ProjectA.csproj", "/some-dir/ProjectB/packages.config", "/some-dir/ProjectA/packages.config"],
676
+ },
677
+ new IncrementMetric()
678
+ {
679
+ Metric = "updater.started",
680
+ Tags = new()
681
+ {
682
+ ["operation"] = "group_update_all_versions"
683
+ }
684
+ },
685
+ new CreatePullRequest()
686
+ {
687
+ Dependencies =
688
+ [
689
+ new ReportedDependency()
690
+ {
691
+ Name = "Some.Package",
692
+ Version = "1.0.1",
693
+ Requirements =
694
+ [
695
+ new ReportedRequirement()
696
+ {
697
+ Requirement = "1.0.1",
698
+ File = "/some-dir/ProjectB/ProjectB.csproj",
699
+ Groups = ["dependencies"],
700
+ Source = new()
701
+ {
702
+ SourceUrl = "https://nuget.example.com/some-package",
703
+ Type = "nuget_repo",
704
+ }
705
+ }
706
+ ],
707
+ PreviousVersion = "1.0.0",
708
+ PreviousRequirements =
709
+ [
710
+ new ReportedRequirement()
711
+ {
712
+ Requirement = "1.0.0",
713
+ File = "/some-dir/ProjectB/ProjectB.csproj",
714
+ Groups = ["dependencies"],
715
+ }
716
+ ],
717
+ },
718
+ new ReportedDependency()
719
+ {
720
+ Name = "Some.Package2",
721
+ Version = "2.0.1",
722
+ Requirements =
723
+ [
724
+ new ReportedRequirement()
725
+ {
726
+ Requirement = "2.0.1",
727
+ File = "/some-dir/ProjectB/packages.config",
728
+ Groups = ["dependencies"],
729
+ Source = new()
730
+ {
731
+ SourceUrl = "https://nuget.example.com/some-package2",
732
+ Type = "nuget_repo",
733
+ }
734
+ }
735
+ ],
736
+ PreviousVersion = "2.0.0",
737
+ PreviousRequirements =
738
+ [
739
+ new ReportedRequirement()
740
+ {
741
+ Requirement = "2.0.0",
742
+ File = "/some-dir/ProjectB/packages.config",
743
+ Groups = ["dependencies"],
744
+ }
745
+ ],
746
+ },
747
+ new ReportedDependency()
748
+ {
749
+ Name = "Some.Package",
750
+ Version = "1.0.1",
751
+ Requirements =
752
+ [
753
+ new ReportedRequirement()
754
+ {
755
+ Requirement = "1.0.1",
756
+ File = "/some-dir/ProjectA/ProjectA.csproj",
757
+ Groups = ["dependencies"],
758
+ Source = new()
759
+ {
760
+ SourceUrl = "https://nuget.example.com/some-package",
761
+ Type = "nuget_repo",
762
+ }
763
+ }
764
+ ],
765
+ PreviousVersion = "1.0.0",
766
+ PreviousRequirements =
767
+ [
768
+ new ReportedRequirement()
769
+ {
770
+ Requirement = "1.0.0",
771
+ File = "/some-dir/ProjectA/ProjectA.csproj",
772
+ Groups = ["dependencies"],
773
+ }
774
+ ],
775
+ },
776
+ new ReportedDependency()
777
+ {
778
+ Name = "Some.Package2",
779
+ Version = "2.0.1",
780
+ Requirements =
781
+ [
782
+ new ReportedRequirement()
783
+ {
784
+ Requirement = "2.0.1",
785
+ File = "/some-dir/ProjectA/packages.config",
786
+ Groups = ["dependencies"],
787
+ Source = new()
788
+ {
789
+ SourceUrl = "https://nuget.example.com/some-package2",
790
+ Type = "nuget_repo",
791
+ }
792
+ }
793
+ ],
794
+ PreviousVersion = "2.0.0",
795
+ PreviousRequirements =
796
+ [
797
+ new ReportedRequirement()
798
+ {
799
+ Requirement = "2.0.0",
800
+ File = "/some-dir/ProjectA/packages.config",
801
+ Groups = ["dependencies"],
802
+ }
803
+ ],
804
+ },
805
+ ],
806
+ UpdatedDependencyFiles =
807
+ [
808
+ new DependencyFile()
809
+ {
810
+ Name = "../ProjectB/ProjectB.csproj",
811
+ Directory = "/some-dir/ProjectB",
812
+ Content = """
813
+ <Project Sdk="Microsoft.NET.Sdk">
814
+ <PropertyGroup>
815
+ <TargetFramework>net8.0</TargetFramework>
816
+ </PropertyGroup>
817
+ <ItemGroup>
818
+ <PackageReference Include="Some.Package" Version="1.0.1" />
819
+ </ItemGroup>
820
+ <ItemGroup>
821
+ <Reference Include="Some.Package2">
822
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
823
+ <Private>True</Private>
824
+ </Reference>
825
+ </ItemGroup>
826
+ </Project>
827
+ """,
828
+ },
829
+ new DependencyFile()
830
+ {
831
+ Name = "../ProjectB/packages.config",
832
+ Directory = "/some-dir/ProjectB",
833
+ Content = """
834
+ <?xml version="1.0" encoding="utf-8"?>
835
+ <packages>
836
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
837
+ </packages>
838
+ """,
839
+ },
840
+ new DependencyFile()
841
+ {
842
+ Name = "ProjectA.csproj",
843
+ Directory = "/some-dir/ProjectA",
844
+ Content = """
845
+ <Project Sdk="Microsoft.NET.Sdk">
846
+ <PropertyGroup>
847
+ <TargetFramework>net8.0</TargetFramework>
848
+ </PropertyGroup>
849
+ <ItemGroup>
850
+ <PackageReference Include="Some.Package" Version="1.0.1" />
851
+ </ItemGroup>
852
+ <ItemGroup>
853
+ <ProjectReference Include="../ProjectB/ProjectB.csproj" />
854
+ </ItemGroup>
855
+ <ItemGroup>
856
+ <Reference Include="Some.Package2">
857
+ <HintPath>..\packages\Some.Package2.2.0.1\lib\net8.0\Some.Package2.dll</HintPath>
858
+ <Private>True</Private>
859
+ </Reference>
860
+ </ItemGroup>
861
+ </Project>
862
+ """,
863
+ },
864
+ new DependencyFile()
865
+ {
866
+ Name = "packages.config",
867
+ Directory = "/some-dir/ProjectA",
868
+ Content = """
869
+ <?xml version="1.0" encoding="utf-8"?>
870
+ <packages>
871
+ <package id="Some.Package2" version="2.0.1" targetFramework="net8.0" />
872
+ </packages>
873
+ """,
874
+ },
875
+ ],
876
+ BaseCommitSha = "TEST-COMMIT-SHA",
877
+ CommitMessage = "TODO: message",
878
+ PrTitle = "TODO: title",
879
+ PrBody = "TODO: body",
880
+ },
881
+ new MarkAsProcessed("TEST-COMMIT-SHA")
260
882
  ]
261
883
  );
262
884
  }
263
885
 
264
- private static async Task RunAsync(Job job, TestFile[] files, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null)
886
+ private static async Task RunAsync(Job job, TestFile[] files, RunResult? expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, string? repoContentsPath = null)
265
887
  {
266
888
  // arrange
267
889
  using var tempDirectory = new TemporaryDirectory();
268
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, tempDirectory.DirectoryPath);
890
+ repoContentsPath ??= tempDirectory.DirectoryPath;
891
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, repoContentsPath);
269
892
  foreach (var (path, content) in files)
270
893
  {
271
- var fullPath = Path.Combine(tempDirectory.DirectoryPath, path);
894
+ var fullPath = Path.Combine(repoContentsPath, path);
272
895
  var directory = Path.GetDirectoryName(fullPath)!;
273
896
  Directory.CreateDirectory(directory);
274
897
  await File.WriteAllTextAsync(fullPath, content);
@@ -277,8 +900,8 @@ public class RunWorkerTests
277
900
  // act
278
901
  var testApiHandler = new TestApiHandler();
279
902
  var worker = new RunWorker(testApiHandler, new TestLogger());
280
- var repoContentsPath = new DirectoryInfo(tempDirectory.DirectoryPath);
281
- var actualResult = await worker.RunAsync(job, repoContentsPath, "TEST-COMMIT-SHA");
903
+ var repoContentsPathDirectoryInfo = new DirectoryInfo(repoContentsPath);
904
+ var actualResult = await worker.RunAsync(job, repoContentsPathDirectoryInfo, "TEST-COMMIT-SHA");
282
905
  var actualApiMessages = testApiHandler.ReceivedMessages.ToArray();
283
906
 
284
907
  // assert
@@ -308,7 +931,7 @@ public class RunWorkerTests
308
931
  }
309
932
  }
310
933
 
311
- private static string SerializeObjectAndType(object obj)
934
+ internal static string SerializeObjectAndType(object obj)
312
935
  {
313
936
  return $"{obj.GetType().Name}:{JsonSerializer.Serialize(obj)}";
314
937
  }