dependabot-nuget 0.322.0 → 0.322.1
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/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +10 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +15 -232
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +1 -154
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/AzurePackageDetailFinder.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGenerator.cs +237 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/GitHubPackageDetailFinder.cs +101 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/GitLabPackageDetailFinder.cs +107 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/HttpFetcher.cs +32 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/IHttpFetcher.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/IPackageDetailFinder.cs +47 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/IPullRequestBodyGenerator.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/SimplePullRequestBodyGenerator.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +7 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +3 -525
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +10 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +1 -856
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -200
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +6 -556
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +9 -73
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +1 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +3 -62
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +13 -563
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +20 -267
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +131 -131
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +0 -203
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGeneratorTests.cs +871 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/IPackageDetailFinderTests.cs +28 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/TestHttpFetcher.cs +23 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +3 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +6 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandlerTests.cs +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +18 -18
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandlerTests.cs +15 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandlerTests.cs +21 -21
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandlerTests.cs +15 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/UpdateHandlersTestsBase.cs +1 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +85 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +1 -159
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +10 -660
- metadata +16 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunResult.cs +0 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestMessageTests.cs +0 -296
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +0 -3592
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatePermittedAndMessageTests.cs +0 -457
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +0 -378
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +0 -175
@@ -1,21 +1,26 @@
|
|
1
|
+
using System.Collections.Immutable;
|
1
2
|
using System.Text;
|
3
|
+
using System.Text.Json;
|
2
4
|
|
3
|
-
using NuGetUpdater.Core.Run.ApiModel;
|
4
|
-
using NuGetUpdater.Core.Run;
|
5
|
-
using Xunit;
|
6
5
|
using NuGetUpdater.Core.Analyze;
|
7
6
|
using NuGetUpdater.Core.Discover;
|
8
|
-
using
|
7
|
+
using NuGetUpdater.Core.Run;
|
8
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
9
|
+
using NuGetUpdater.Core.Test.Update;
|
10
|
+
|
11
|
+
using Xunit;
|
9
12
|
|
10
13
|
namespace NuGetUpdater.Core.Test.Run;
|
11
14
|
|
15
|
+
using TestFile = (string Path, string Content);
|
16
|
+
using RawTestFile = (string Path, byte[] Content);
|
17
|
+
|
12
18
|
public class EndToEndTests
|
13
19
|
{
|
14
20
|
[Fact]
|
15
|
-
public async Task
|
21
|
+
public async Task WithPackageReference()
|
16
22
|
{
|
17
|
-
await
|
18
|
-
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true, UseNewFileUpdater = true },
|
23
|
+
await RunAsync(
|
19
24
|
packages: [
|
20
25
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net9.0"),
|
21
26
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net9.0"),
|
@@ -53,11 +58,6 @@ public class EndToEndTests
|
|
53
58
|
discoveryWorker: null, // use real worker
|
54
59
|
analyzeWorker: null, // use real worker
|
55
60
|
updaterWorker: null, // use real worker
|
56
|
-
expectedResult: new()
|
57
|
-
{
|
58
|
-
Base64DependencyFiles = [],
|
59
|
-
BaseCommitSha = "TEST-COMMIT-SHA",
|
60
|
-
},
|
61
61
|
expectedApiMessages: [
|
62
62
|
new IncrementMetric()
|
63
63
|
{
|
@@ -140,9 +140,9 @@ public class EndToEndTests
|
|
140
140
|
},
|
141
141
|
],
|
142
142
|
BaseCommitSha = "TEST-COMMIT-SHA",
|
143
|
-
CommitMessage =
|
144
|
-
PrTitle =
|
145
|
-
PrBody =
|
143
|
+
CommitMessage = TestPullRequestCommitMessage,
|
144
|
+
PrTitle = TestPullRequestTitle,
|
145
|
+
PrBody = TestPullRequestBody,
|
146
146
|
DependencyGroup = null,
|
147
147
|
},
|
148
148
|
new MarkAsProcessed("TEST-COMMIT-SHA")
|
@@ -151,10 +151,9 @@ public class EndToEndTests
|
|
151
151
|
}
|
152
152
|
|
153
153
|
[Fact]
|
154
|
-
public async Task
|
154
|
+
public async Task WithPackagesConfig()
|
155
155
|
{
|
156
|
-
await
|
157
|
-
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true, UseNewFileUpdater = true },
|
156
|
+
await RunAsync(
|
158
157
|
packages: [
|
159
158
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
160
159
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net45"),
|
@@ -207,11 +206,6 @@ public class EndToEndTests
|
|
207
206
|
discoveryWorker: null, // use real worker
|
208
207
|
analyzeWorker: null, // use real worker
|
209
208
|
updaterWorker: null, // use real worker
|
210
|
-
expectedResult: new()
|
211
|
-
{
|
212
|
-
Base64DependencyFiles = [],
|
213
|
-
BaseCommitSha = "TEST-COMMIT-SHA",
|
214
|
-
},
|
215
209
|
expectedApiMessages: [
|
216
210
|
new IncrementMetric()
|
217
211
|
{
|
@@ -311,9 +305,9 @@ public class EndToEndTests
|
|
311
305
|
},
|
312
306
|
],
|
313
307
|
BaseCommitSha = "TEST-COMMIT-SHA",
|
314
|
-
CommitMessage =
|
315
|
-
PrTitle =
|
316
|
-
PrBody =
|
308
|
+
CommitMessage = TestPullRequestCommitMessage,
|
309
|
+
PrTitle = TestPullRequestTitle,
|
310
|
+
PrBody = TestPullRequestBody,
|
317
311
|
DependencyGroup = null,
|
318
312
|
},
|
319
313
|
new MarkAsProcessed("TEST-COMMIT-SHA")
|
@@ -322,10 +316,10 @@ public class EndToEndTests
|
|
322
316
|
}
|
323
317
|
|
324
318
|
[Fact]
|
325
|
-
public async Task
|
319
|
+
public async Task LegacyProject_With_PackageReference()
|
326
320
|
{
|
327
|
-
var experimentsManager = new ExperimentsManager()
|
328
|
-
await
|
321
|
+
var experimentsManager = new ExperimentsManager();
|
322
|
+
await RunAsync(
|
329
323
|
experimentsManager: experimentsManager,
|
330
324
|
packages: [
|
331
325
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
@@ -393,11 +387,6 @@ public class EndToEndTests
|
|
393
387
|
}),
|
394
388
|
analyzeWorker: null, // use real worker
|
395
389
|
updaterWorker: null, // use real worker
|
396
|
-
expectedResult: new()
|
397
|
-
{
|
398
|
-
Base64DependencyFiles = [],
|
399
|
-
BaseCommitSha = "TEST-COMMIT-SHA",
|
400
|
-
},
|
401
390
|
expectedApiMessages: [
|
402
391
|
new IncrementMetric()
|
403
392
|
{
|
@@ -483,9 +472,9 @@ public class EndToEndTests
|
|
483
472
|
},
|
484
473
|
],
|
485
474
|
BaseCommitSha = "TEST-COMMIT-SHA",
|
486
|
-
CommitMessage =
|
487
|
-
PrTitle =
|
488
|
-
PrBody =
|
475
|
+
CommitMessage = TestPullRequestCommitMessage,
|
476
|
+
PrTitle = TestPullRequestTitle,
|
477
|
+
PrBody = TestPullRequestBody,
|
489
478
|
DependencyGroup = null,
|
490
479
|
},
|
491
480
|
new MarkAsProcessed("TEST-COMMIT-SHA")
|
@@ -493,10 +482,8 @@ public class EndToEndTests
|
|
493
482
|
);
|
494
483
|
}
|
495
484
|
|
496
|
-
[
|
497
|
-
|
498
|
-
[InlineData(false)]
|
499
|
-
public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories(bool useLegacyUpdateHandler)
|
485
|
+
[Fact]
|
486
|
+
public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories()
|
500
487
|
{
|
501
488
|
// this test passes `null` for discovery, analyze, and update workers to fully test the desired behavior
|
502
489
|
|
@@ -504,88 +491,7 @@ public class EndToEndTests
|
|
504
491
|
// library1.csproj - top level dependency, already up to date
|
505
492
|
// library2.csproj - top level dependency, needs direct update
|
506
493
|
// library3.csproj - transitive dependency, needs pin
|
507
|
-
|
508
|
-
? new[]
|
509
|
-
{
|
510
|
-
new DependencyFile()
|
511
|
-
{
|
512
|
-
Directory = "/",
|
513
|
-
Name = "Directory.Build.props",
|
514
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
|
515
|
-
ContentEncoding = "base64",
|
516
|
-
},
|
517
|
-
new DependencyFile()
|
518
|
-
{
|
519
|
-
Directory = "/",
|
520
|
-
Name = "Directory.Build.targets",
|
521
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
|
522
|
-
ContentEncoding = "base64",
|
523
|
-
},
|
524
|
-
new DependencyFile()
|
525
|
-
{
|
526
|
-
Directory = "/",
|
527
|
-
Name = "Directory.Packages.props",
|
528
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
529
|
-
<Project>
|
530
|
-
<PropertyGroup>
|
531
|
-
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
532
|
-
</PropertyGroup>
|
533
|
-
</Project>
|
534
|
-
""")),
|
535
|
-
ContentEncoding = "base64",
|
536
|
-
},
|
537
|
-
new DependencyFile()
|
538
|
-
{
|
539
|
-
Directory = "/library1",
|
540
|
-
Name = "library1.csproj",
|
541
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
542
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
543
|
-
<PropertyGroup>
|
544
|
-
<TargetFramework>net8.0</TargetFramework>
|
545
|
-
</PropertyGroup>
|
546
|
-
<ItemGroup>
|
547
|
-
<PackageReference Include="Some.Package" Version="2.0.0" />
|
548
|
-
</ItemGroup>
|
549
|
-
</Project>
|
550
|
-
""")),
|
551
|
-
ContentEncoding = "base64",
|
552
|
-
},
|
553
|
-
new DependencyFile()
|
554
|
-
{
|
555
|
-
Directory = "/library2",
|
556
|
-
Name = "library2.csproj",
|
557
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
558
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
559
|
-
<PropertyGroup>
|
560
|
-
<TargetFramework>net8.0</TargetFramework>
|
561
|
-
</PropertyGroup>
|
562
|
-
<ItemGroup>
|
563
|
-
<PackageReference Include="Some.Package" Version="1.0.0" />
|
564
|
-
</ItemGroup>
|
565
|
-
</Project>
|
566
|
-
""")),
|
567
|
-
ContentEncoding = "base64",
|
568
|
-
},
|
569
|
-
new DependencyFile()
|
570
|
-
{
|
571
|
-
Directory = "/library3",
|
572
|
-
Name = "library3.csproj",
|
573
|
-
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
574
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
575
|
-
<PropertyGroup>
|
576
|
-
<TargetFramework>net8.0</TargetFramework>
|
577
|
-
</PropertyGroup>
|
578
|
-
<ItemGroup>
|
579
|
-
<PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
|
580
|
-
</ItemGroup>
|
581
|
-
</Project>
|
582
|
-
""")),
|
583
|
-
ContentEncoding = "base64",
|
584
|
-
}
|
585
|
-
}
|
586
|
-
: [];
|
587
|
-
await RunWorkerTests.RunAsync(
|
588
|
-
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true, UseLegacyUpdateHandler = useLegacyUpdateHandler },
|
494
|
+
await RunAsync(
|
589
495
|
packages: [
|
590
496
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
591
497
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
@@ -666,11 +572,6 @@ public class EndToEndTests
|
|
666
572
|
discoveryWorker: null,
|
667
573
|
analyzeWorker: null,
|
668
574
|
updaterWorker: null,
|
669
|
-
expectedResult: new RunResult()
|
670
|
-
{
|
671
|
-
Base64DependencyFiles = base64DependencyFiles,
|
672
|
-
BaseCommitSha = "TEST-COMMIT-SHA",
|
673
|
-
},
|
674
575
|
expectedApiMessages: [
|
675
576
|
new UpdatedDependencyList()
|
676
577
|
{
|
@@ -837,13 +738,112 @@ public class EndToEndTests
|
|
837
738
|
}
|
838
739
|
],
|
839
740
|
BaseCommitSha = "TEST-COMMIT-SHA",
|
840
|
-
CommitMessage =
|
841
|
-
PrTitle =
|
842
|
-
PrBody =
|
741
|
+
CommitMessage = TestPullRequestCommitMessage,
|
742
|
+
PrTitle = TestPullRequestTitle,
|
743
|
+
PrBody = TestPullRequestBody,
|
843
744
|
DependencyGroup = null,
|
844
745
|
},
|
845
746
|
new MarkAsProcessed("TEST-COMMIT-SHA")
|
846
747
|
]
|
847
748
|
);
|
848
749
|
}
|
750
|
+
|
751
|
+
public const string TestPullRequestCommitMessage = "test-pull-request-commit-message";
|
752
|
+
public const string TestPullRequestTitle = "test-pull-request-title";
|
753
|
+
public const string TestPullRequestBody = "test-pull-request-body";
|
754
|
+
|
755
|
+
internal static Task RunAsync(Job job, TestFile[] files, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
|
756
|
+
{
|
757
|
+
var rawTestFiles = files.Select(f => (f.Path, Encoding.UTF8.GetBytes(f.Content))).ToArray();
|
758
|
+
return RunAsync(job, rawTestFiles, discoveryWorker, analyzeWorker, updaterWorker, expectedApiMessages, packages, experimentsManager, repoContentsPath);
|
759
|
+
}
|
760
|
+
|
761
|
+
private static async Task RunAsync(Job job, RawTestFile[] rawFiles, IDiscoveryWorker? discoveryWorker, IAnalyzeWorker? analyzeWorker, IUpdaterWorker? updaterWorker, object[] expectedApiMessages, MockNuGetPackage[]? packages = null, ExperimentsManager? experimentsManager = null, string? repoContentsPath = null)
|
762
|
+
{
|
763
|
+
// arrange
|
764
|
+
using var tempDirectory = new TemporaryDirectory();
|
765
|
+
repoContentsPath ??= tempDirectory.DirectoryPath;
|
766
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, repoContentsPath);
|
767
|
+
foreach (var (path, content) in rawFiles)
|
768
|
+
{
|
769
|
+
var fullPath = Path.Combine(repoContentsPath, path);
|
770
|
+
var directory = Path.GetDirectoryName(fullPath)!;
|
771
|
+
Directory.CreateDirectory(directory);
|
772
|
+
await File.WriteAllBytesAsync(fullPath, content);
|
773
|
+
}
|
774
|
+
|
775
|
+
// act
|
776
|
+
experimentsManager ??= new ExperimentsManager();
|
777
|
+
var testApiHandler = new TestApiHandler();
|
778
|
+
var logger = new TestLogger();
|
779
|
+
var jobId = "TEST-JOB-ID";
|
780
|
+
discoveryWorker ??= new DiscoveryWorker(jobId, experimentsManager, logger);
|
781
|
+
analyzeWorker ??= new AnalyzeWorker(jobId, experimentsManager, logger);
|
782
|
+
updaterWorker ??= new UpdaterWorker(jobId, experimentsManager, logger);
|
783
|
+
|
784
|
+
var worker = new RunWorker(jobId, testApiHandler, discoveryWorker, analyzeWorker, updaterWorker, logger);
|
785
|
+
var repoContentsPathDirectoryInfo = new DirectoryInfo(repoContentsPath);
|
786
|
+
await worker.RunAsync(job, repoContentsPathDirectoryInfo, repoContentsPathDirectoryInfo, "TEST-COMMIT-SHA", experimentsManager);
|
787
|
+
var actualApiMessages = testApiHandler.ReceivedMessages
|
788
|
+
.Select(m =>
|
789
|
+
{
|
790
|
+
object newObject;
|
791
|
+
switch (m.Object)
|
792
|
+
{
|
793
|
+
// this isn't the place to verify the generated text
|
794
|
+
case CreatePullRequest create:
|
795
|
+
newObject = create with { CommitMessage = TestPullRequestCommitMessage, PrTitle = TestPullRequestTitle, PrBody = TestPullRequestBody };
|
796
|
+
break;
|
797
|
+
case UpdatePullRequest update:
|
798
|
+
newObject = update with { CommitMessage = TestPullRequestCommitMessage, PrTitle = TestPullRequestTitle, PrBody = TestPullRequestBody };
|
799
|
+
break;
|
800
|
+
// don't test callstacks
|
801
|
+
case UnknownError unknown:
|
802
|
+
var message = (string)unknown.Details["error-message"];
|
803
|
+
var stackTraceOffset = message.IndexOf('\n');
|
804
|
+
if (stackTraceOffset >= 0)
|
805
|
+
{
|
806
|
+
var messageWithoutStackTrace = message[..stackTraceOffset].TrimEnd('\r');
|
807
|
+
unknown.Details["error-message"] = messageWithoutStackTrace;
|
808
|
+
}
|
809
|
+
|
810
|
+
newObject = unknown;
|
811
|
+
break;
|
812
|
+
default:
|
813
|
+
newObject = m.Object;
|
814
|
+
break;
|
815
|
+
}
|
816
|
+
|
817
|
+
return (m.Type, Object: newObject);
|
818
|
+
}
|
819
|
+
).ToArray();
|
820
|
+
|
821
|
+
// assert
|
822
|
+
for (int i = 0; i < Math.Min(actualApiMessages.Length, expectedApiMessages.Length); i++)
|
823
|
+
{
|
824
|
+
var actualMessage = actualApiMessages[i];
|
825
|
+
var expectedMessage = expectedApiMessages[i];
|
826
|
+
Assert.Equal(expectedMessage.GetType(), actualMessage.Type);
|
827
|
+
|
828
|
+
var expectedContent = SerializeObjectAndType(expectedMessage);
|
829
|
+
var actualContent = SerializeObjectAndType(actualMessage.Object);
|
830
|
+
Assert.Equal(expectedContent, actualContent);
|
831
|
+
}
|
832
|
+
|
833
|
+
if (actualApiMessages.Length > expectedApiMessages.Length)
|
834
|
+
{
|
835
|
+
var extraApiMessages = actualApiMessages.Skip(expectedApiMessages.Length).Select(m => SerializeObjectAndType(m.Object)).ToArray();
|
836
|
+
Assert.Fail($"Expected {expectedApiMessages.Length} API messages, but got {extraApiMessages.Length} extra:\n\t{string.Join("\n\t", extraApiMessages)}");
|
837
|
+
}
|
838
|
+
if (expectedApiMessages.Length > actualApiMessages.Length)
|
839
|
+
{
|
840
|
+
var missingApiMessages = expectedApiMessages.Skip(actualApiMessages.Length).Select(m => SerializeObjectAndType(m)).ToArray();
|
841
|
+
Assert.Fail($"Expected {expectedApiMessages.Length} API messages, but only got {actualApiMessages.Length}; missing:\n\t{string.Join("\n\t", missingApiMessages)}");
|
842
|
+
}
|
843
|
+
}
|
844
|
+
|
845
|
+
internal static string SerializeObjectAndType(object obj)
|
846
|
+
{
|
847
|
+
return $"{obj.GetType().Name}:{JsonSerializer.Serialize(obj, RunWorker.SerializerOptions)}";
|
848
|
+
}
|
849
849
|
}
|
@@ -513,25 +513,6 @@ public class MiscellaneousTests
|
|
513
513
|
];
|
514
514
|
}
|
515
515
|
|
516
|
-
[Theory]
|
517
|
-
[MemberData(nameof(RequirementsFromIgnoredVersionsData))]
|
518
|
-
public void RequirementsFromIgnoredVersions(string dependencyName, Condition[] ignoreConditions, Requirement[] expectedRequirements)
|
519
|
-
{
|
520
|
-
var job = new Job()
|
521
|
-
{
|
522
|
-
Source = new()
|
523
|
-
{
|
524
|
-
Provider = "github",
|
525
|
-
Repo = "some/repo"
|
526
|
-
},
|
527
|
-
IgnoreConditions = ignoreConditions
|
528
|
-
};
|
529
|
-
var actualRequirements = RunWorker.GetIgnoredRequirementsForDependency(job, dependencyName);
|
530
|
-
var actualRequirementsStrings = string.Join("|", actualRequirements.Select(r => r.ToString()));
|
531
|
-
var expectedRequirementsStrings = string.Join("|", expectedRequirements.Select(r => r.ToString()));
|
532
|
-
Assert.Equal(expectedRequirementsStrings, actualRequirementsStrings);
|
533
|
-
}
|
534
|
-
|
535
516
|
[Theory]
|
536
517
|
[MemberData(nameof(DependencyInfoFromJobData))]
|
537
518
|
public void DependencyInfoFromJob(Job job, Dependency dependency, DependencyInfo expectedDependencyInfo)
|
@@ -542,16 +523,6 @@ public class MiscellaneousTests
|
|
542
523
|
Assert.Equal(expectedString, actualString);
|
543
524
|
}
|
544
525
|
|
545
|
-
[Theory]
|
546
|
-
[MemberData(nameof(GetIncrementMetricData))]
|
547
|
-
public void GetIncrementMetric(Job job, IncrementMetric expected)
|
548
|
-
{
|
549
|
-
var actual = RunWorker.GetIncrementMetric(job);
|
550
|
-
var actualJson = HttpApiHandler.Serialize(actual);
|
551
|
-
var expectedJson = HttpApiHandler.Serialize(expected);
|
552
|
-
Assert.Equal(expectedJson, actualJson);
|
553
|
-
}
|
554
|
-
|
555
526
|
[Theory]
|
556
527
|
[MemberData(nameof(GetUpdateOperationsData))]
|
557
528
|
public void GetUpdateOperations(WorkspaceDiscoveryResult discovery, (string ProjectPath, string DependencyName)[] expectedUpdateOperations)
|
@@ -633,60 +604,6 @@ public class MiscellaneousTests
|
|
633
604
|
];
|
634
605
|
}
|
635
606
|
|
636
|
-
public static IEnumerable<object?[]> RequirementsFromIgnoredVersionsData()
|
637
|
-
{
|
638
|
-
yield return
|
639
|
-
[
|
640
|
-
// dependencyName
|
641
|
-
"Some.Package",
|
642
|
-
// ignoredConditions
|
643
|
-
new Condition[]
|
644
|
-
{
|
645
|
-
new()
|
646
|
-
{
|
647
|
-
DependencyName = "SOME.PACKAGE",
|
648
|
-
VersionRequirement = Requirement.Parse("> 1.2.3")
|
649
|
-
},
|
650
|
-
new()
|
651
|
-
{
|
652
|
-
DependencyName = "some.package",
|
653
|
-
VersionRequirement = Requirement.Parse("<= 2.0.0")
|
654
|
-
},
|
655
|
-
new()
|
656
|
-
{
|
657
|
-
DependencyName = "Unrelated.Package",
|
658
|
-
VersionRequirement = Requirement.Parse("= 3.4.5")
|
659
|
-
}
|
660
|
-
},
|
661
|
-
// expectedRequirements
|
662
|
-
new Requirement[]
|
663
|
-
{
|
664
|
-
new IndividualRequirement(">", NuGetVersion.Parse("1.2.3")),
|
665
|
-
new IndividualRequirement("<=", NuGetVersion.Parse("2.0.0")),
|
666
|
-
}
|
667
|
-
];
|
668
|
-
|
669
|
-
// version requirement is null => ignore all
|
670
|
-
yield return
|
671
|
-
[
|
672
|
-
// dependencyName
|
673
|
-
"Some.Package",
|
674
|
-
// ignoredConditions
|
675
|
-
new Condition[]
|
676
|
-
{
|
677
|
-
new()
|
678
|
-
{
|
679
|
-
DependencyName = "Some.Package"
|
680
|
-
}
|
681
|
-
},
|
682
|
-
// expectedRequirements
|
683
|
-
new Requirement[]
|
684
|
-
{
|
685
|
-
new IndividualRequirement(">", NuGetVersion.Parse("0.0.0"))
|
686
|
-
}
|
687
|
-
];
|
688
|
-
}
|
689
|
-
|
690
607
|
public static IEnumerable<object[]> DependencyInfoFromJobData()
|
691
608
|
{
|
692
609
|
// with security advisory
|
@@ -774,124 +691,4 @@ public class MiscellaneousTests
|
|
774
691
|
}
|
775
692
|
];
|
776
693
|
}
|
777
|
-
|
778
|
-
public static IEnumerable<object?[]> GetIncrementMetricData()
|
779
|
-
{
|
780
|
-
static Job GetJob(AllowedUpdate[] allowed, bool securityUpdatesOnly, bool updatingAPullRequest)
|
781
|
-
{
|
782
|
-
return new Job()
|
783
|
-
{
|
784
|
-
AllowedUpdates = allowed.ToImmutableArray(),
|
785
|
-
Source = new()
|
786
|
-
{
|
787
|
-
Provider = "github",
|
788
|
-
Repo = "some/repo"
|
789
|
-
},
|
790
|
-
SecurityUpdatesOnly = securityUpdatesOnly,
|
791
|
-
UpdatingAPullRequest = updatingAPullRequest,
|
792
|
-
};
|
793
|
-
}
|
794
|
-
|
795
|
-
// version update
|
796
|
-
yield return
|
797
|
-
[
|
798
|
-
GetJob(
|
799
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }],
|
800
|
-
securityUpdatesOnly: false,
|
801
|
-
updatingAPullRequest: false),
|
802
|
-
new IncrementMetric()
|
803
|
-
{
|
804
|
-
Metric = "updater.started",
|
805
|
-
Tags =
|
806
|
-
{
|
807
|
-
["operation"] = "group_update_all_versions"
|
808
|
-
}
|
809
|
-
}
|
810
|
-
];
|
811
|
-
|
812
|
-
// version update - existing pr
|
813
|
-
yield return
|
814
|
-
[
|
815
|
-
GetJob(
|
816
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }],
|
817
|
-
securityUpdatesOnly: false,
|
818
|
-
updatingAPullRequest: true),
|
819
|
-
new IncrementMetric()
|
820
|
-
{
|
821
|
-
Metric = "updater.started",
|
822
|
-
Tags =
|
823
|
-
{
|
824
|
-
["operation"] = "update_version_pr"
|
825
|
-
}
|
826
|
-
}
|
827
|
-
];
|
828
|
-
|
829
|
-
// create security pr - allowed security update
|
830
|
-
yield return
|
831
|
-
[
|
832
|
-
GetJob(
|
833
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }, new AllowedUpdate() { UpdateType = UpdateType.Security }],
|
834
|
-
securityUpdatesOnly: false,
|
835
|
-
updatingAPullRequest: false),
|
836
|
-
new IncrementMetric()
|
837
|
-
{
|
838
|
-
Metric = "updater.started",
|
839
|
-
Tags =
|
840
|
-
{
|
841
|
-
["operation"] = "create_security_pr"
|
842
|
-
}
|
843
|
-
}
|
844
|
-
];
|
845
|
-
|
846
|
-
// create security pr - security only
|
847
|
-
yield return
|
848
|
-
[
|
849
|
-
GetJob(
|
850
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All } ],
|
851
|
-
securityUpdatesOnly: true,
|
852
|
-
updatingAPullRequest: false),
|
853
|
-
new IncrementMetric()
|
854
|
-
{
|
855
|
-
Metric = "updater.started",
|
856
|
-
Tags =
|
857
|
-
{
|
858
|
-
["operation"] = "create_security_pr"
|
859
|
-
}
|
860
|
-
}
|
861
|
-
];
|
862
|
-
|
863
|
-
// update security pr - allowed security update
|
864
|
-
yield return
|
865
|
-
[
|
866
|
-
GetJob(
|
867
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All }, new AllowedUpdate() { UpdateType = UpdateType.Security } ],
|
868
|
-
securityUpdatesOnly: false,
|
869
|
-
updatingAPullRequest: true),
|
870
|
-
new IncrementMetric()
|
871
|
-
{
|
872
|
-
Metric = "updater.started",
|
873
|
-
Tags =
|
874
|
-
{
|
875
|
-
["operation"] = "update_security_pr"
|
876
|
-
}
|
877
|
-
}
|
878
|
-
];
|
879
|
-
|
880
|
-
// update security pr - security only
|
881
|
-
yield return
|
882
|
-
[
|
883
|
-
GetJob(
|
884
|
-
allowed: [new AllowedUpdate() { UpdateType = UpdateType.All } ],
|
885
|
-
securityUpdatesOnly: true,
|
886
|
-
updatingAPullRequest: true),
|
887
|
-
new IncrementMetric()
|
888
|
-
{
|
889
|
-
Metric = "updater.started",
|
890
|
-
Tags =
|
891
|
-
{
|
892
|
-
["operation"] = "update_security_pr"
|
893
|
-
}
|
894
|
-
}
|
895
|
-
];
|
896
|
-
}
|
897
694
|
}
|