dependabot-nuget 0.310.0 → 0.312.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.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +1 -1
- data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation.Test/DotNetPackageCorrelation.Test.csproj +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/BadResponseException.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +121 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/ClosePullRequest.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CreatePullRequest.cs +20 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +26 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/MessageBase.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UnknownError.cs +12 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdatePullRequest.cs +16 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +19 -50
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/IApiHandler.cs +33 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +49 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +41 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +13 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +6 -25
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +13 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +74 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +3 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +3 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +58 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +37 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +116 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +231 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +32 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +714 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +44 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/TestApiHandler.cs +2 -39
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestHttpServer.cs +9 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +99 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationBaseTests.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +1 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LoggerTests.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +66 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- metadata +30 -27
@@ -16,8 +16,6 @@ using Xunit;
|
|
16
16
|
|
17
17
|
namespace NuGetUpdater.Core.Test.Run;
|
18
18
|
|
19
|
-
using static NuGetUpdater.Core.Utilities.EOLHandling;
|
20
|
-
|
21
19
|
using TestFile = (string Path, string Content);
|
22
20
|
using RawTestFile = (string Path, byte[] Content);
|
23
21
|
|
@@ -499,7 +497,7 @@ public class RunWorkerTests
|
|
499
497
|
}
|
500
498
|
|
501
499
|
[Fact]
|
502
|
-
public async Task
|
500
|
+
public async Task ErrorsThrownFromDiscoveryWorkerAreForwaredToApiHandler()
|
503
501
|
{
|
504
502
|
await RunAsync(
|
505
503
|
packages:
|
@@ -537,17 +535,499 @@ public class RunWorkerTests
|
|
537
535
|
],
|
538
536
|
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
539
537
|
{
|
540
|
-
throw new HttpRequestException(message: null, inner: null, statusCode: HttpStatusCode.Unauthorized);
|
538
|
+
throw new HttpRequestException(message: null, inner: null, statusCode: HttpStatusCode.Unauthorized);
|
539
|
+
}),
|
540
|
+
analyzeWorker: new TestAnalyzeWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
541
|
+
updaterWorker: new TestUpdaterWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
542
|
+
expectedResult: new RunResult()
|
543
|
+
{
|
544
|
+
Base64DependencyFiles = [],
|
545
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
546
|
+
},
|
547
|
+
expectedApiMessages:
|
548
|
+
[
|
549
|
+
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
550
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
551
|
+
]
|
552
|
+
);
|
553
|
+
}
|
554
|
+
|
555
|
+
[Fact]
|
556
|
+
public async Task ErrorsReturnedFromDiscoveryWorkerAreForwaredToApiHandler()
|
557
|
+
{
|
558
|
+
await RunAsync(
|
559
|
+
packages: [],
|
560
|
+
job: new Job()
|
561
|
+
{
|
562
|
+
Source = new()
|
563
|
+
{
|
564
|
+
Provider = "github",
|
565
|
+
Repo = "test/repo",
|
566
|
+
Directory = "/",
|
567
|
+
}
|
568
|
+
},
|
569
|
+
files: [],
|
570
|
+
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
571
|
+
{
|
572
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
573
|
+
{
|
574
|
+
Path = "/",
|
575
|
+
IsSuccess = false,
|
576
|
+
Projects = [],
|
577
|
+
Error = new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
578
|
+
});
|
579
|
+
}),
|
580
|
+
analyzeWorker: new TestAnalyzeWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
581
|
+
updaterWorker: new TestUpdaterWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
582
|
+
expectedResult: new RunResult()
|
583
|
+
{
|
584
|
+
Base64DependencyFiles = [],
|
585
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
586
|
+
},
|
587
|
+
expectedApiMessages:
|
588
|
+
[
|
589
|
+
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
590
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
591
|
+
]
|
592
|
+
);
|
593
|
+
}
|
594
|
+
|
595
|
+
[Fact]
|
596
|
+
public async Task ErrorsThrownFromAnalyzeWorkerAreForwaredToApiHandler()
|
597
|
+
{
|
598
|
+
await RunAsync(
|
599
|
+
packages: [],
|
600
|
+
job: new Job()
|
601
|
+
{
|
602
|
+
Source = new()
|
603
|
+
{
|
604
|
+
Provider = "github",
|
605
|
+
Repo = "test/repo",
|
606
|
+
Directory = "/",
|
607
|
+
}
|
608
|
+
},
|
609
|
+
files:
|
610
|
+
[
|
611
|
+
("NuGet.Config", """
|
612
|
+
<configuration>
|
613
|
+
<packageSources>
|
614
|
+
<clear />
|
615
|
+
<add key="private_feed" value="http://example.com/nuget/index.json" allowInsecureConnections="true" />
|
616
|
+
</packageSources>
|
617
|
+
</configuration>
|
618
|
+
"""),
|
619
|
+
("project.csproj", """
|
620
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
621
|
+
<PropertyGroup>
|
622
|
+
<TargetFramework>net8.0</TargetFramework>
|
623
|
+
</PropertyGroup>
|
624
|
+
<ItemGroup>
|
625
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
626
|
+
</ItemGroup>
|
627
|
+
</Project>
|
628
|
+
""")
|
629
|
+
],
|
630
|
+
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
631
|
+
{
|
632
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
633
|
+
{
|
634
|
+
Path = "",
|
635
|
+
Projects = [
|
636
|
+
new()
|
637
|
+
{
|
638
|
+
FilePath = "project.csproj",
|
639
|
+
Dependencies = [new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])],
|
640
|
+
ImportedFiles = [],
|
641
|
+
AdditionalFiles = [],
|
642
|
+
}
|
643
|
+
]
|
644
|
+
});
|
645
|
+
}),
|
646
|
+
analyzeWorker: new TestAnalyzeWorker((_input) =>
|
647
|
+
{
|
648
|
+
throw new HttpRequestException(message: null, inner: null, statusCode: HttpStatusCode.Unauthorized);
|
649
|
+
}),
|
650
|
+
updaterWorker: new TestUpdaterWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
651
|
+
expectedResult: new RunResult()
|
652
|
+
{
|
653
|
+
Base64DependencyFiles = [],
|
654
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
655
|
+
},
|
656
|
+
expectedApiMessages:
|
657
|
+
[
|
658
|
+
new UpdatedDependencyList()
|
659
|
+
{
|
660
|
+
Dependencies =
|
661
|
+
[
|
662
|
+
new ReportedDependency()
|
663
|
+
{
|
664
|
+
Name = "Some.Package",
|
665
|
+
Version = "1.0.0",
|
666
|
+
Requirements =
|
667
|
+
[
|
668
|
+
new ReportedRequirement()
|
669
|
+
{
|
670
|
+
Requirement = "1.0.0",
|
671
|
+
File = "/project.csproj",
|
672
|
+
Groups = ["dependencies"],
|
673
|
+
}
|
674
|
+
]
|
675
|
+
}
|
676
|
+
],
|
677
|
+
DependencyFiles = ["/project.csproj"],
|
678
|
+
},
|
679
|
+
new IncrementMetric()
|
680
|
+
{
|
681
|
+
Metric = "updater.started",
|
682
|
+
Tags = new()
|
683
|
+
{
|
684
|
+
["operation"] = "group_update_all_versions"
|
685
|
+
}
|
686
|
+
},
|
687
|
+
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
688
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
689
|
+
]
|
690
|
+
);
|
691
|
+
}
|
692
|
+
|
693
|
+
[Fact]
|
694
|
+
public async Task ErrorsReturnedFromAnalyzeWorkerAreForwaredToApiHandler()
|
695
|
+
{
|
696
|
+
await RunAsync(
|
697
|
+
packages: [],
|
698
|
+
job: new Job()
|
699
|
+
{
|
700
|
+
Source = new()
|
701
|
+
{
|
702
|
+
Provider = "github",
|
703
|
+
Repo = "test/repo",
|
704
|
+
Directory = "/",
|
705
|
+
}
|
706
|
+
},
|
707
|
+
files: [
|
708
|
+
("project.csproj", """
|
709
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
710
|
+
<PropertyGroup>
|
711
|
+
<TargetFramework>net8.0</TargetFramework>
|
712
|
+
</PropertyGroup>
|
713
|
+
<ItemGroup>
|
714
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
715
|
+
</ItemGroup>
|
716
|
+
</Project>
|
717
|
+
""")
|
718
|
+
],
|
719
|
+
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
720
|
+
{
|
721
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
722
|
+
{
|
723
|
+
Path = "",
|
724
|
+
Projects = [
|
725
|
+
new()
|
726
|
+
{
|
727
|
+
FilePath = "project.csproj",
|
728
|
+
Dependencies = [new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])],
|
729
|
+
ImportedFiles = [],
|
730
|
+
AdditionalFiles = [],
|
731
|
+
}
|
732
|
+
]
|
733
|
+
});
|
734
|
+
}),
|
735
|
+
analyzeWorker: new TestAnalyzeWorker((_input) =>
|
736
|
+
{
|
737
|
+
return Task.FromResult(new AnalysisResult()
|
738
|
+
{
|
739
|
+
UpdatedVersion = "",
|
740
|
+
CanUpdate = false,
|
741
|
+
VersionComesFromMultiDependencyProperty = false,
|
742
|
+
UpdatedDependencies = [],
|
743
|
+
Error = new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
744
|
+
});
|
745
|
+
}),
|
746
|
+
updaterWorker: new TestUpdaterWorker((_input) => throw new NotImplementedException("shouldn't get this far")),
|
747
|
+
expectedResult: new RunResult()
|
748
|
+
{
|
749
|
+
Base64DependencyFiles = [
|
750
|
+
new()
|
751
|
+
{
|
752
|
+
Directory = "/",
|
753
|
+
Name = "project.csproj",
|
754
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
755
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
756
|
+
<PropertyGroup>
|
757
|
+
<TargetFramework>net8.0</TargetFramework>
|
758
|
+
</PropertyGroup>
|
759
|
+
<ItemGroup>
|
760
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
761
|
+
</ItemGroup>
|
762
|
+
</Project>
|
763
|
+
""")),
|
764
|
+
ContentEncoding = "base64"
|
765
|
+
}
|
766
|
+
],
|
767
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
768
|
+
},
|
769
|
+
expectedApiMessages:
|
770
|
+
[
|
771
|
+
new UpdatedDependencyList()
|
772
|
+
{
|
773
|
+
Dependencies =
|
774
|
+
[
|
775
|
+
new ReportedDependency()
|
776
|
+
{
|
777
|
+
Name = "Some.Package",
|
778
|
+
Version = "1.0.0",
|
779
|
+
Requirements =
|
780
|
+
[
|
781
|
+
new ReportedRequirement()
|
782
|
+
{
|
783
|
+
Requirement = "1.0.0",
|
784
|
+
File = "/project.csproj",
|
785
|
+
Groups = ["dependencies"],
|
786
|
+
}
|
787
|
+
]
|
788
|
+
}
|
789
|
+
],
|
790
|
+
DependencyFiles = ["/project.csproj"],
|
791
|
+
},
|
792
|
+
new IncrementMetric()
|
793
|
+
{
|
794
|
+
Metric = "updater.started",
|
795
|
+
Tags = new()
|
796
|
+
{
|
797
|
+
["operation"] = "group_update_all_versions"
|
798
|
+
}
|
799
|
+
},
|
800
|
+
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
801
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
802
|
+
]
|
803
|
+
);
|
804
|
+
}
|
805
|
+
|
806
|
+
[Fact]
|
807
|
+
public async Task ErrorsThrownFromUpdaterWorkerAreForwaredToApiHandler()
|
808
|
+
{
|
809
|
+
await RunAsync(
|
810
|
+
packages: [],
|
811
|
+
job: new Job()
|
812
|
+
{
|
813
|
+
Source = new()
|
814
|
+
{
|
815
|
+
Provider = "github",
|
816
|
+
Repo = "test/repo",
|
817
|
+
Directory = "/",
|
818
|
+
}
|
819
|
+
},
|
820
|
+
files:
|
821
|
+
[
|
822
|
+
("NuGet.Config", """
|
823
|
+
<configuration>
|
824
|
+
<packageSources>
|
825
|
+
<clear />
|
826
|
+
<add key="private_feed" value="http://example.com/nuget/index.json" allowInsecureConnections="true" />
|
827
|
+
</packageSources>
|
828
|
+
</configuration>
|
829
|
+
"""),
|
830
|
+
("project.csproj", """
|
831
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
832
|
+
<PropertyGroup>
|
833
|
+
<TargetFramework>net8.0</TargetFramework>
|
834
|
+
</PropertyGroup>
|
835
|
+
<ItemGroup>
|
836
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
837
|
+
</ItemGroup>
|
838
|
+
</Project>
|
839
|
+
""")
|
840
|
+
],
|
841
|
+
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
842
|
+
{
|
843
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
844
|
+
{
|
845
|
+
Path = "",
|
846
|
+
Projects = [
|
847
|
+
new()
|
848
|
+
{
|
849
|
+
FilePath = "project.csproj",
|
850
|
+
Dependencies = [new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])],
|
851
|
+
ImportedFiles = [],
|
852
|
+
AdditionalFiles = [],
|
853
|
+
}
|
854
|
+
]
|
855
|
+
});
|
856
|
+
}),
|
857
|
+
analyzeWorker: new TestAnalyzeWorker((_input) =>
|
858
|
+
{
|
859
|
+
return Task.FromResult(new AnalysisResult()
|
860
|
+
{
|
861
|
+
UpdatedVersion = "1.0.1",
|
862
|
+
CanUpdate = true,
|
863
|
+
UpdatedDependencies =
|
864
|
+
[
|
865
|
+
new("Some.Package", "1.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package"),
|
866
|
+
]
|
867
|
+
});
|
868
|
+
}),
|
869
|
+
updaterWorker: new TestUpdaterWorker((_input) =>
|
870
|
+
{
|
871
|
+
throw new HttpRequestException(message: null, inner: null, statusCode: HttpStatusCode.Unauthorized);
|
872
|
+
}),
|
873
|
+
expectedResult: new RunResult()
|
874
|
+
{
|
875
|
+
Base64DependencyFiles = [],
|
876
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
877
|
+
},
|
878
|
+
expectedApiMessages:
|
879
|
+
[
|
880
|
+
new UpdatedDependencyList()
|
881
|
+
{
|
882
|
+
Dependencies =
|
883
|
+
[
|
884
|
+
new ReportedDependency()
|
885
|
+
{
|
886
|
+
Name = "Some.Package",
|
887
|
+
Version = "1.0.0",
|
888
|
+
Requirements =
|
889
|
+
[
|
890
|
+
new ReportedRequirement()
|
891
|
+
{
|
892
|
+
Requirement = "1.0.0",
|
893
|
+
File = "/project.csproj",
|
894
|
+
Groups = ["dependencies"],
|
895
|
+
}
|
896
|
+
]
|
897
|
+
}
|
898
|
+
],
|
899
|
+
DependencyFiles = ["/project.csproj"],
|
900
|
+
},
|
901
|
+
new IncrementMetric()
|
902
|
+
{
|
903
|
+
Metric = "updater.started",
|
904
|
+
Tags = new()
|
905
|
+
{
|
906
|
+
["operation"] = "group_update_all_versions"
|
907
|
+
}
|
908
|
+
},
|
909
|
+
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
910
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
911
|
+
]
|
912
|
+
);
|
913
|
+
}
|
914
|
+
|
915
|
+
[Fact]
|
916
|
+
public async Task ErrorsReturnedFromUpdaterWorkerAreForwaredToApiHandler()
|
917
|
+
{
|
918
|
+
await RunAsync(
|
919
|
+
packages: [],
|
920
|
+
job: new Job()
|
921
|
+
{
|
922
|
+
Source = new()
|
923
|
+
{
|
924
|
+
Provider = "github",
|
925
|
+
Repo = "test/repo",
|
926
|
+
Directory = "/",
|
927
|
+
}
|
928
|
+
},
|
929
|
+
files:
|
930
|
+
[
|
931
|
+
("project.csproj", """
|
932
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
933
|
+
<PropertyGroup>
|
934
|
+
<TargetFramework>net8.0</TargetFramework>
|
935
|
+
</PropertyGroup>
|
936
|
+
<ItemGroup>
|
937
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
938
|
+
</ItemGroup>
|
939
|
+
</Project>
|
940
|
+
""")
|
941
|
+
],
|
942
|
+
discoveryWorker: new TestDiscoveryWorker((_input) =>
|
943
|
+
{
|
944
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
945
|
+
{
|
946
|
+
Path = "",
|
947
|
+
Projects = [
|
948
|
+
new()
|
949
|
+
{
|
950
|
+
FilePath = "project.csproj",
|
951
|
+
Dependencies = [new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"])],
|
952
|
+
ImportedFiles = [],
|
953
|
+
AdditionalFiles = [],
|
954
|
+
}
|
955
|
+
]
|
956
|
+
});
|
957
|
+
}),
|
958
|
+
analyzeWorker: new TestAnalyzeWorker((_input) =>
|
959
|
+
{
|
960
|
+
return Task.FromResult(new AnalysisResult()
|
961
|
+
{
|
962
|
+
UpdatedVersion = "1.0.1",
|
963
|
+
CanUpdate = true,
|
964
|
+
UpdatedDependencies =
|
965
|
+
[
|
966
|
+
new("Some.Package", "1.0.1", DependencyType.Unknown, TargetFrameworks: ["net8.0"], InfoUrl: "https://nuget.example.com/some-package"),
|
967
|
+
]
|
968
|
+
});
|
969
|
+
}),
|
970
|
+
updaterWorker: new TestUpdaterWorker((_input) =>
|
971
|
+
{
|
972
|
+
return Task.FromResult(new UpdateOperationResult()
|
973
|
+
{
|
974
|
+
UpdateOperations = [],
|
975
|
+
Error = new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
976
|
+
});
|
541
977
|
}),
|
542
|
-
analyzeWorker: TestAnalyzeWorker.FromResults(),
|
543
|
-
updaterWorker: TestUpdaterWorker.FromResults(),
|
544
978
|
expectedResult: new RunResult()
|
545
979
|
{
|
546
|
-
Base64DependencyFiles = [
|
980
|
+
Base64DependencyFiles = [
|
981
|
+
new()
|
982
|
+
{
|
983
|
+
Directory = "/",
|
984
|
+
Name = "project.csproj",
|
985
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
986
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
987
|
+
<PropertyGroup>
|
988
|
+
<TargetFramework>net8.0</TargetFramework>
|
989
|
+
</PropertyGroup>
|
990
|
+
<ItemGroup>
|
991
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
992
|
+
</ItemGroup>
|
993
|
+
</Project>
|
994
|
+
""")),
|
995
|
+
ContentEncoding = "base64"
|
996
|
+
}
|
997
|
+
],
|
547
998
|
BaseCommitSha = "TEST-COMMIT-SHA",
|
548
999
|
},
|
549
1000
|
expectedApiMessages:
|
550
1001
|
[
|
1002
|
+
new UpdatedDependencyList()
|
1003
|
+
{
|
1004
|
+
Dependencies =
|
1005
|
+
[
|
1006
|
+
new ReportedDependency()
|
1007
|
+
{
|
1008
|
+
Name = "Some.Package",
|
1009
|
+
Version = "1.0.0",
|
1010
|
+
Requirements =
|
1011
|
+
[
|
1012
|
+
new ReportedRequirement()
|
1013
|
+
{
|
1014
|
+
Requirement = "1.0.0",
|
1015
|
+
File = "/project.csproj",
|
1016
|
+
Groups = ["dependencies"],
|
1017
|
+
}
|
1018
|
+
]
|
1019
|
+
}
|
1020
|
+
],
|
1021
|
+
DependencyFiles = ["/project.csproj"],
|
1022
|
+
},
|
1023
|
+
new IncrementMetric()
|
1024
|
+
{
|
1025
|
+
Metric = "updater.started",
|
1026
|
+
Tags = new()
|
1027
|
+
{
|
1028
|
+
["operation"] = "group_update_all_versions"
|
1029
|
+
}
|
1030
|
+
},
|
551
1031
|
new PrivateSourceAuthenticationFailure(["http://example.com/nuget/index.json"]),
|
552
1032
|
new MarkAsProcessed("TEST-COMMIT-SHA")
|
553
1033
|
]
|
@@ -2295,6 +2775,162 @@ public class RunWorkerTests
|
|
2295
2775
|
);
|
2296
2776
|
}
|
2297
2777
|
|
2778
|
+
[Fact]
|
2779
|
+
public async Task AnalysisResultWithoutUpdatedDependenciesDoesNotCauseError()
|
2780
|
+
{
|
2781
|
+
await RunAsync(
|
2782
|
+
job: new()
|
2783
|
+
{
|
2784
|
+
Source = new()
|
2785
|
+
{
|
2786
|
+
Provider = "github",
|
2787
|
+
Repo = "test/repo",
|
2788
|
+
},
|
2789
|
+
Dependencies = [
|
2790
|
+
"Some.Package"
|
2791
|
+
],
|
2792
|
+
},
|
2793
|
+
files: [
|
2794
|
+
("project.csproj", "contents irrelevant")
|
2795
|
+
],
|
2796
|
+
discoveryWorker: new TestDiscoveryWorker(_input =>
|
2797
|
+
{
|
2798
|
+
return Task.FromResult(new WorkspaceDiscoveryResult()
|
2799
|
+
{
|
2800
|
+
Path = "",
|
2801
|
+
Projects = [
|
2802
|
+
new()
|
2803
|
+
{
|
2804
|
+
FilePath = "project.csproj",
|
2805
|
+
Dependencies = [
|
2806
|
+
new("Some.Package", "1.0.0", DependencyType.PackageReference)
|
2807
|
+
],
|
2808
|
+
ImportedFiles = [],
|
2809
|
+
AdditionalFiles = [],
|
2810
|
+
}
|
2811
|
+
]
|
2812
|
+
});
|
2813
|
+
}),
|
2814
|
+
analyzeWorker: new TestAnalyzeWorker(_input =>
|
2815
|
+
{
|
2816
|
+
return Task.FromResult(new AnalysisResult()
|
2817
|
+
{
|
2818
|
+
CanUpdate = true,
|
2819
|
+
UpdatedVersion = "1.1.0",
|
2820
|
+
UpdatedDependencies = [], // this is what was causing the problem
|
2821
|
+
});
|
2822
|
+
}),
|
2823
|
+
updaterWorker: new TestUpdaterWorker(async input =>
|
2824
|
+
{
|
2825
|
+
var repoRootPath = input.Item1;
|
2826
|
+
var filePath = input.Item2;
|
2827
|
+
await File.WriteAllTextAsync(Path.Join(repoRootPath, filePath), "updated contents irrelevant");
|
2828
|
+
return new UpdateOperationResult()
|
2829
|
+
{
|
2830
|
+
UpdateOperations = [
|
2831
|
+
new DirectUpdate()
|
2832
|
+
{
|
2833
|
+
DependencyName = "Some.Package",
|
2834
|
+
NewVersion = NuGetVersion.Parse("1.1.0"),
|
2835
|
+
UpdatedFiles = ["project.csproj"]
|
2836
|
+
}
|
2837
|
+
]
|
2838
|
+
};
|
2839
|
+
}),
|
2840
|
+
expectedResult: new()
|
2841
|
+
{
|
2842
|
+
Base64DependencyFiles = [
|
2843
|
+
new()
|
2844
|
+
{
|
2845
|
+
Directory = "/",
|
2846
|
+
Name = "project.csproj",
|
2847
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("contents irrelevant")),
|
2848
|
+
ContentEncoding = "base64"
|
2849
|
+
}
|
2850
|
+
],
|
2851
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
2852
|
+
},
|
2853
|
+
expectedApiMessages: [
|
2854
|
+
new UpdatedDependencyList()
|
2855
|
+
{
|
2856
|
+
Dependencies = [
|
2857
|
+
new()
|
2858
|
+
{
|
2859
|
+
Name = "Some.Package",
|
2860
|
+
Version = "1.0.0",
|
2861
|
+
Requirements = [
|
2862
|
+
new()
|
2863
|
+
{
|
2864
|
+
Requirement = "1.0.0",
|
2865
|
+
File = "/project.csproj",
|
2866
|
+
Groups = ["dependencies"],
|
2867
|
+
}
|
2868
|
+
]
|
2869
|
+
}
|
2870
|
+
],
|
2871
|
+
DependencyFiles = ["/project.csproj"]
|
2872
|
+
},
|
2873
|
+
new IncrementMetric()
|
2874
|
+
{
|
2875
|
+
Metric = "updater.started",
|
2876
|
+
Tags = new()
|
2877
|
+
{
|
2878
|
+
["operation"] = "group_update_all_versions"
|
2879
|
+
}
|
2880
|
+
},
|
2881
|
+
new CreatePullRequest()
|
2882
|
+
{
|
2883
|
+
Dependencies =
|
2884
|
+
[
|
2885
|
+
new ReportedDependency()
|
2886
|
+
{
|
2887
|
+
Name = "Some.Package",
|
2888
|
+
Version = "1.1.0",
|
2889
|
+
Requirements =
|
2890
|
+
[
|
2891
|
+
new ReportedRequirement()
|
2892
|
+
{
|
2893
|
+
Requirement = "1.1.0",
|
2894
|
+
File = "/project.csproj",
|
2895
|
+
Groups = ["dependencies"],
|
2896
|
+
Source = new()
|
2897
|
+
{
|
2898
|
+
SourceUrl = null,
|
2899
|
+
Type = "nuget_repo",
|
2900
|
+
}
|
2901
|
+
}
|
2902
|
+
],
|
2903
|
+
PreviousVersion = "1.0.0",
|
2904
|
+
PreviousRequirements =
|
2905
|
+
[
|
2906
|
+
new ReportedRequirement()
|
2907
|
+
{
|
2908
|
+
Requirement = "1.0.0",
|
2909
|
+
File = "/project.csproj",
|
2910
|
+
Groups = ["dependencies"],
|
2911
|
+
}
|
2912
|
+
],
|
2913
|
+
}
|
2914
|
+
],
|
2915
|
+
UpdatedDependencyFiles =
|
2916
|
+
[
|
2917
|
+
new DependencyFile()
|
2918
|
+
{
|
2919
|
+
Name = "project.csproj",
|
2920
|
+
Directory = "/",
|
2921
|
+
Content = "updated contents irrelevant",
|
2922
|
+
},
|
2923
|
+
],
|
2924
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
2925
|
+
CommitMessage = TestPullRequestCommitMessage,
|
2926
|
+
PrTitle = TestPullRequestTitle,
|
2927
|
+
PrBody = TestPullRequestBody,
|
2928
|
+
},
|
2929
|
+
new MarkAsProcessed("TEST-COMMIT-SHA"),
|
2930
|
+
]
|
2931
|
+
);
|
2932
|
+
}
|
2933
|
+
|
2298
2934
|
[Fact]
|
2299
2935
|
public async Task ByteOrderMarksAreDetectedAndRestored()
|
2300
2936
|
{
|
@@ -2784,6 +3420,50 @@ public class RunWorkerTests
|
|
2784
3420
|
);
|
2785
3421
|
}
|
2786
3422
|
|
3423
|
+
[Fact]
|
3424
|
+
public async Task UnknownErrorsGenerateAllRequiredApiCalls()
|
3425
|
+
{
|
3426
|
+
await RunAsync(
|
3427
|
+
job: new Job()
|
3428
|
+
{
|
3429
|
+
Source = new()
|
3430
|
+
{
|
3431
|
+
Provider = "github",
|
3432
|
+
Repo = "test/repo",
|
3433
|
+
Directory = "some-dir",
|
3434
|
+
}
|
3435
|
+
},
|
3436
|
+
packages: [],
|
3437
|
+
files: [],
|
3438
|
+
discoveryWorker: new TestDiscoveryWorker(_input =>
|
3439
|
+
{
|
3440
|
+
throw new FileNotFoundException("some required file is missing");
|
3441
|
+
}),
|
3442
|
+
analyzeWorker: TestAnalyzeWorker.FromResults(), // unreachable
|
3443
|
+
updaterWorker: TestUpdaterWorker.FromResults(), // unreachable
|
3444
|
+
expectedResult: new RunResult()
|
3445
|
+
{
|
3446
|
+
Base64DependencyFiles = [],
|
3447
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
3448
|
+
},
|
3449
|
+
expectedApiMessages:
|
3450
|
+
[
|
3451
|
+
new UnknownError(new FileNotFoundException("some required file is missing"), "TEST-JOB-ID"), // from record_update_job_error
|
3452
|
+
new UnknownError(new FileNotFoundException("some required file is missing"), "TEST-JOB-ID"), // from record_update_job_unknown_error
|
3453
|
+
new IncrementMetric()
|
3454
|
+
{
|
3455
|
+
Metric = "updater.update_job_unknown_error",
|
3456
|
+
Tags = new()
|
3457
|
+
{
|
3458
|
+
["package_manager"] = "nuget",
|
3459
|
+
["class_name"] = "FileNotFoundException"
|
3460
|
+
}
|
3461
|
+
},
|
3462
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
3463
|
+
]
|
3464
|
+
);
|
3465
|
+
}
|
3466
|
+
|
2787
3467
|
internal static Task RunAsync(Job job, TestFile[] files, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, RunResult expectedResult, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
|
2788
3468
|
{
|
2789
3469
|
var rawTestFiles = files.Select(f => (f.Path, Encoding.UTF8.GetBytes(f.Content))).ToArray();
|
@@ -2818,13 +3498,36 @@ public class RunWorkerTests
|
|
2818
3498
|
var actualResult = await worker.RunAsync(job, repoContentsPathDirectoryInfo, "TEST-COMMIT-SHA");
|
2819
3499
|
var actualApiMessages = testApiHandler.ReceivedMessages
|
2820
3500
|
.Select(m =>
|
2821
|
-
|
3501
|
+
{
|
3502
|
+
object newObject;
|
3503
|
+
switch (m.Object)
|
2822
3504
|
{
|
2823
3505
|
// this isn't the place to verify the generated text
|
2824
|
-
CreatePullRequest create
|
2825
|
-
|
2826
|
-
|
3506
|
+
case CreatePullRequest create:
|
3507
|
+
newObject = create with { CommitMessage = TestPullRequestCommitMessage, PrTitle = TestPullRequestTitle, PrBody = TestPullRequestBody };
|
3508
|
+
break;
|
3509
|
+
case UpdatePullRequest update:
|
3510
|
+
newObject = update with { CommitMessage = TestPullRequestCommitMessage, PrTitle = TestPullRequestTitle, PrBody = TestPullRequestBody };
|
3511
|
+
break;
|
3512
|
+
// don't test callstacks
|
3513
|
+
case UnknownError unknown:
|
3514
|
+
var message = (string)unknown.Details["error-message"];
|
3515
|
+
var stackTraceOffset = message.IndexOf('\n');
|
3516
|
+
if (stackTraceOffset >= 0)
|
3517
|
+
{
|
3518
|
+
var messageWithoutStackTrace = message[..stackTraceOffset].TrimEnd('\r');
|
3519
|
+
unknown.Details["error-message"] = messageWithoutStackTrace;
|
3520
|
+
}
|
3521
|
+
|
3522
|
+
newObject = unknown;
|
3523
|
+
break;
|
3524
|
+
default:
|
3525
|
+
newObject = m.Object;
|
3526
|
+
break;
|
2827
3527
|
}
|
3528
|
+
|
3529
|
+
return (m.Type, Object: newObject);
|
3530
|
+
}
|
2828
3531
|
).ToArray();
|
2829
3532
|
|
2830
3533
|
// assert
|