dependabot-nuget 0.280.0 → 0.282.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Common.props +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +9 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +16 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/{SdkPackageUpdater.cs → PackageReferenceUpdater.cs} +97 -37
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +26 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +12 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +14 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +25 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/CompatibilityCheckerTests.cs +7 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolverEnvironment.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/ExpectedUpdateOperationResult.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +14 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/{UpdateWorkerTests.Sdk.cs → UpdateWorkerTests.PackageReference.cs} +200 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +221 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +56 -18
- data/lib/dependabot/nuget/file_fetcher.rb +58 -21
- data/lib/dependabot/nuget/file_updater.rb +1 -0
- data/lib/dependabot/nuget/native_helpers.rb +10 -16
- metadata +19 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs +0 -21
@@ -44,13 +44,14 @@ internal static partial class MSBuildHelper
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
47
|
-
public static async Task SidelineGlobalJsonAsync(string currentDirectory, string rootDirectory, Func<Task> action, bool retainMSBuildSdks = false)
|
47
|
+
public static async Task SidelineGlobalJsonAsync(string currentDirectory, string rootDirectory, Func<Task> action, ILogger? logger = null, bool retainMSBuildSdks = false)
|
48
48
|
{
|
49
|
+
logger ??= new ConsoleLogger();
|
49
50
|
var candidateDirectories = PathHelper.GetAllDirectoriesToRoot(currentDirectory, rootDirectory);
|
50
51
|
var globalJsonPaths = candidateDirectories.Select(d => Path.Combine(d, "global.json")).Where(File.Exists).Select(p => (p, p + Guid.NewGuid().ToString())).ToArray();
|
51
52
|
foreach (var (globalJsonPath, tempGlobalJsonPath) in globalJsonPaths)
|
52
53
|
{
|
53
|
-
|
54
|
+
logger.Log($"Temporarily removing `global.json` from `{Path.GetDirectoryName(globalJsonPath)}`{(retainMSBuildSdks ? " and retaining MSBuild SDK declarations" : string.Empty)}.");
|
54
55
|
File.Move(globalJsonPath, tempGlobalJsonPath);
|
55
56
|
if (retainMSBuildSdks)
|
56
57
|
{
|
@@ -78,7 +79,7 @@ internal static partial class MSBuildHelper
|
|
78
79
|
{
|
79
80
|
foreach (var (globalJsonpath, tempGlobalJsonPath) in globalJsonPaths)
|
80
81
|
{
|
81
|
-
|
82
|
+
logger.Log($"Restoring `global.json` to `{Path.GetDirectoryName(globalJsonpath)}`.");
|
82
83
|
File.Move(tempGlobalJsonPath, globalJsonpath, overwrite: retainMSBuildSdks);
|
83
84
|
}
|
84
85
|
}
|
@@ -316,7 +317,7 @@ internal static partial class MSBuildHelper
|
|
316
317
|
return false;
|
317
318
|
}
|
318
319
|
|
319
|
-
internal static async Task<bool> DependenciesAreCoherentAsync(string repoRoot, string projectPath, string targetFramework, Dependency[] packages,
|
320
|
+
internal static async Task<bool> DependenciesAreCoherentAsync(string repoRoot, string projectPath, string targetFramework, Dependency[] packages, ILogger logger)
|
320
321
|
{
|
321
322
|
var tempDirectory = Directory.CreateTempSubdirectory("package-dependency-coherence_");
|
322
323
|
try
|
@@ -339,19 +340,7 @@ internal static partial class MSBuildHelper
|
|
339
340
|
return Environment.GetEnvironmentVariable("UseNewNugetPackageResolver") == "true";
|
340
341
|
}
|
341
342
|
|
342
|
-
internal static async Task<Dependency[]?> ResolveDependencyConflicts(string repoRoot, string projectPath, string targetFramework, Dependency[] packages, Dependency[] update,
|
343
|
-
{
|
344
|
-
if (UseNewDependencySolver())
|
345
|
-
{
|
346
|
-
return await ResolveDependencyConflictsNew(repoRoot, projectPath, targetFramework, packages, update, logger);
|
347
|
-
}
|
348
|
-
else
|
349
|
-
{
|
350
|
-
return await ResolveDependencyConflictsOld(repoRoot, projectPath, targetFramework, packages, logger);
|
351
|
-
}
|
352
|
-
}
|
353
|
-
|
354
|
-
internal static async Task<Dependency[]?> ResolveDependencyConflictsNew(string repoRoot, string projectPath, string targetFramework, Dependency[] packages, Dependency[] update, Logger logger)
|
343
|
+
internal static async Task<Dependency[]?> ResolveDependencyConflicts(string repoRoot, string projectPath, string targetFramework, Dependency[] packages, Dependency[] update, ILogger logger)
|
355
344
|
{
|
356
345
|
var tempDirectory = Directory.CreateTempSubdirectory("package-dependency-coherence_");
|
357
346
|
PackageManager packageManager = new PackageManager(repoRoot, projectPath);
|
@@ -417,7 +406,7 @@ internal static partial class MSBuildHelper
|
|
417
406
|
// Update all to new versions
|
418
407
|
foreach (var package in existingDuplicate)
|
419
408
|
{
|
420
|
-
string updateResult = await packageManager.UpdateVersion(existingDuplicate, package, targetFramework, Path.GetDirectoryName(projectPath));
|
409
|
+
string updateResult = await packageManager.UpdateVersion(existingDuplicate, package, targetFramework, Path.GetDirectoryName(projectPath), logger);
|
421
410
|
}
|
422
411
|
}
|
423
412
|
|
@@ -433,7 +422,7 @@ internal static partial class MSBuildHelper
|
|
433
422
|
// Update all to new versions
|
434
423
|
foreach (var package in existingPackages)
|
435
424
|
{
|
436
|
-
string updateResult = await packageManager.UpdateVersion(existingPackages, package, targetFramework, Path.GetDirectoryName(projectPath));
|
425
|
+
string updateResult = await packageManager.UpdateVersion(existingPackages, package, targetFramework, Path.GetDirectoryName(projectPath), logger);
|
437
426
|
}
|
438
427
|
}
|
439
428
|
|
@@ -509,7 +498,7 @@ internal static partial class MSBuildHelper
|
|
509
498
|
}
|
510
499
|
}
|
511
500
|
|
512
|
-
internal static async Task<Dependency[]?>
|
501
|
+
internal static async Task<Dependency[]?> ResolveDependencyConflictsWithBruteForce(string repoRoot, string projectPath, string targetFramework, Dependency[] packages, ILogger logger)
|
513
502
|
{
|
514
503
|
var tempDirectory = Directory.CreateTempSubdirectory("package-dependency-coherence_");
|
515
504
|
try
|
@@ -712,6 +701,8 @@ internal static partial class MSBuildHelper
|
|
712
701
|
<GenerateDependencyFile>true</GenerateDependencyFile>
|
713
702
|
<RunAnalyzers>false</RunAnalyzers>
|
714
703
|
<NuGetInteractive>false</NuGetInteractive>
|
704
|
+
<DesignTimeBuild>true</DesignTimeBuild>
|
705
|
+
<TargetPlatformVersion Condition=" $(TargetFramework.Contains('-')) ">1.0</TargetPlatformVersion>
|
715
706
|
</PropertyGroup>
|
716
707
|
<ItemGroup>
|
717
708
|
{packageReferences}
|
@@ -762,7 +753,7 @@ internal static partial class MSBuildHelper
|
|
762
753
|
string projectPath,
|
763
754
|
string targetFramework,
|
764
755
|
IReadOnlyCollection<Dependency> packages,
|
765
|
-
|
756
|
+
ILogger? logger = null)
|
766
757
|
{
|
767
758
|
var tempDirectory = Directory.CreateTempSubdirectory("package-dependency-resolution_");
|
768
759
|
try
|
@@ -823,13 +814,24 @@ internal static partial class MSBuildHelper
|
|
823
814
|
}
|
824
815
|
}
|
825
816
|
|
826
|
-
internal static
|
817
|
+
internal static string? GetMissingFile(string output)
|
827
818
|
{
|
828
819
|
var missingFilePattern = new Regex(@"The imported project \""(?<FilePath>.*)\"" was not found");
|
829
820
|
var match = missingFilePattern.Match(output);
|
830
821
|
if (match.Success)
|
831
822
|
{
|
832
|
-
|
823
|
+
return match.Groups["FilePath"].Value;
|
824
|
+
}
|
825
|
+
|
826
|
+
return null;
|
827
|
+
}
|
828
|
+
|
829
|
+
internal static void ThrowOnMissingFile(string output)
|
830
|
+
{
|
831
|
+
var missingFile = GetMissingFile(output);
|
832
|
+
if (missingFile is not null)
|
833
|
+
{
|
834
|
+
throw new MissingFileException(missingFile);
|
833
835
|
}
|
834
836
|
}
|
835
837
|
|
@@ -20,7 +20,7 @@ internal static class NuGetHelper
|
|
20
20
|
return false;
|
21
21
|
}
|
22
22
|
|
23
|
-
internal static async Task<bool> DownloadNuGetPackagesAsync(string repoRoot, string projectPath, IReadOnlyCollection<Dependency> packages,
|
23
|
+
internal static async Task<bool> DownloadNuGetPackagesAsync(string repoRoot, string projectPath, IReadOnlyCollection<Dependency> packages, ILogger logger)
|
24
24
|
{
|
25
25
|
var tempDirectory = Directory.CreateTempSubdirectory("msbuild_sdk_restore_");
|
26
26
|
try
|
@@ -36,7 +36,7 @@ public class AnalyzeWorkerTestBase
|
|
36
36
|
var discoveryPath = Path.GetFullPath(DiscoveryWorker.DiscoveryResultFileName, directoryPath);
|
37
37
|
var dependencyPath = Path.GetFullPath(relativeDependencyPath, directoryPath);
|
38
38
|
|
39
|
-
var worker = new AnalyzeWorker(new
|
39
|
+
var worker = new AnalyzeWorker(new TestLogger());
|
40
40
|
var result = await worker.RunWithErrorHandlingAsync(directoryPath, discoveryPath, dependencyPath);
|
41
41
|
return result;
|
42
42
|
});
|
@@ -739,7 +739,7 @@ public partial class AnalyzeWorkerTests : AnalyzeWorkerTestBase
|
|
739
739
|
ErrorDetails = "<some package feed>",
|
740
740
|
UpdatedVersion = "",
|
741
741
|
UpdatedDependencies = [],
|
742
|
-
}, new
|
742
|
+
}, new TestLogger());
|
743
743
|
var discoveryContents = await File.ReadAllTextAsync(Path.Combine(temporaryDirectory.DirectoryPath, "Some.Dependency.json"));
|
744
744
|
|
745
745
|
// raw result file should look like this:
|
@@ -30,7 +30,7 @@ public class CompatibilityCheckerTests
|
|
30
30
|
projectFrameworks,
|
31
31
|
isDevDependency,
|
32
32
|
packageFrameworks,
|
33
|
-
new
|
33
|
+
new TestLogger());
|
34
34
|
|
35
35
|
Assert.True(result);
|
36
36
|
}
|
@@ -53,7 +53,7 @@ public class CompatibilityCheckerTests
|
|
53
53
|
projectFrameworks,
|
54
54
|
isDevDependency,
|
55
55
|
packageFrameworks,
|
56
|
-
new
|
56
|
+
new TestLogger());
|
57
57
|
|
58
58
|
Assert.False(result);
|
59
59
|
}
|
@@ -76,7 +76,7 @@ public class CompatibilityCheckerTests
|
|
76
76
|
projectFrameworks,
|
77
77
|
isDevDependency,
|
78
78
|
packageFrameworks,
|
79
|
-
new
|
79
|
+
new TestLogger());
|
80
80
|
|
81
81
|
Assert.False(result);
|
82
82
|
}
|
@@ -97,7 +97,7 @@ public class CompatibilityCheckerTests
|
|
97
97
|
projectFrameworks,
|
98
98
|
isDevDependency,
|
99
99
|
packageFrameworks,
|
100
|
-
new
|
100
|
+
new TestLogger());
|
101
101
|
|
102
102
|
Assert.True(result);
|
103
103
|
}
|
@@ -118,7 +118,7 @@ public class CompatibilityCheckerTests
|
|
118
118
|
projectFrameworks,
|
119
119
|
isDevDependency,
|
120
120
|
packageFrameworks,
|
121
|
-
new
|
121
|
+
new TestLogger());
|
122
122
|
|
123
123
|
Assert.False(result);
|
124
124
|
}
|
@@ -138,7 +138,7 @@ public class CompatibilityCheckerTests
|
|
138
138
|
projectFrameworks,
|
139
139
|
isDevDependency,
|
140
140
|
packageFrameworks,
|
141
|
-
new
|
141
|
+
new TestLogger());
|
142
142
|
|
143
143
|
Assert.False(result);
|
144
144
|
}
|
@@ -161,7 +161,7 @@ public class CompatibilityCheckerTests
|
|
161
161
|
projectFrameworks,
|
162
162
|
isDevDependency,
|
163
163
|
packageFrameworks,
|
164
|
-
new
|
164
|
+
new TestLogger());
|
165
165
|
|
166
166
|
Assert.True(result);
|
167
167
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace NuGetUpdater.Core.Test;
|
2
|
+
|
3
|
+
/// <summary>
|
4
|
+
/// Prepares the environment to use the new dependency solver.
|
5
|
+
/// </summary>
|
6
|
+
public class DependencySolverEnvironment : TemporaryEnvironment
|
7
|
+
{
|
8
|
+
public DependencySolverEnvironment(bool useDependencySolver = true)
|
9
|
+
: base([("UseNewNugetPackageResolver", useDependencySolver ? "true" : "false")])
|
10
|
+
{
|
11
|
+
}
|
12
|
+
}
|
@@ -24,7 +24,7 @@ public class DiscoveryWorkerTestBase
|
|
24
24
|
{
|
25
25
|
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, directoryPath);
|
26
26
|
|
27
|
-
var worker = new DiscoveryWorker(new
|
27
|
+
var worker = new DiscoveryWorker(new TestLogger());
|
28
28
|
var result = await worker.RunWithErrorHandlingAsync(directoryPath, workspacePath);
|
29
29
|
return result;
|
30
30
|
});
|
@@ -32,7 +32,7 @@ public class DotnetToolsJsonBuildFileTests
|
|
32
32
|
basePath: "/",
|
33
33
|
path: "/.config/dotnet-tools.json",
|
34
34
|
contents: DotnetToolsJson,
|
35
|
-
logger: new
|
35
|
+
logger: new TestLogger());
|
36
36
|
|
37
37
|
[Fact]
|
38
38
|
public void GetDependencies_ReturnsDependencies()
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs
CHANGED
@@ -20,7 +20,7 @@ public class CompatibilityCheckerFacts
|
|
20
20
|
[InlineData("net4.8", "netstandard1.3")]
|
21
21
|
public void PackageContainsCompatibleFramework(string projectTfm, string packageTfm)
|
22
22
|
{
|
23
|
-
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new
|
23
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new TestLogger());
|
24
24
|
|
25
25
|
Assert.True(result);
|
26
26
|
}
|
@@ -37,7 +37,7 @@ public class CompatibilityCheckerFacts
|
|
37
37
|
[InlineData("net7.0", "net48")]
|
38
38
|
public void PackageContainsIncompatibleFramework(string projectTfm, string packageTfm)
|
39
39
|
{
|
40
|
-
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new
|
40
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new TestLogger());
|
41
41
|
|
42
42
|
Assert.False(result);
|
43
43
|
}
|
@@ -48,7 +48,7 @@ public class CompatibilityCheckerFacts
|
|
48
48
|
[InlineData(new[] { "net6.0", "net6.0-windows10.0.19041" }, new[] { "net6.0", ".NETStandard2.0" })]
|
49
49
|
public void PackageContainsCompatibleFrameworks(string[] projectTfms, string[] packageTfms)
|
50
50
|
{
|
51
|
-
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new
|
51
|
+
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new TestLogger());
|
52
52
|
|
53
53
|
Assert.True(result);
|
54
54
|
}
|
@@ -57,7 +57,7 @@ public class CompatibilityCheckerFacts
|
|
57
57
|
[InlineData(new[] { "net7.0", "net472" }, new[] { "net5.0" })]
|
58
58
|
public void PackageContainsIncompatibleFrameworks(string[] projectTfms, string[] packageTfms)
|
59
59
|
{
|
60
|
-
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new
|
60
|
+
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new TestLogger());
|
61
61
|
|
62
62
|
Assert.False(result);
|
63
63
|
}
|
@@ -276,7 +276,7 @@ public class RunWorkerTests
|
|
276
276
|
|
277
277
|
// act
|
278
278
|
var testApiHandler = new TestApiHandler();
|
279
|
-
var worker = new RunWorker(testApiHandler, new
|
279
|
+
var worker = new RunWorker(testApiHandler, new TestLogger());
|
280
280
|
var repoContentsPath = new DirectoryInfo(tempDirectory.DirectoryPath);
|
281
281
|
var actualResult = await worker.RunAsync(job, repoContentsPath, "TEST-COMMIT-SHA");
|
282
282
|
var actualApiMessages = testApiHandler.ReceivedMessages.ToArray();
|
@@ -30,7 +30,7 @@ public class PackagesConfigUpdaterTests : TestBase
|
|
30
30
|
""",
|
31
31
|
"Newtonsoft.Json",
|
32
32
|
"7.0.1",
|
33
|
-
|
33
|
+
"../packages"
|
34
34
|
];
|
35
35
|
|
36
36
|
// project without namespace
|
@@ -48,7 +48,7 @@ public class PackagesConfigUpdaterTests : TestBase
|
|
48
48
|
""",
|
49
49
|
"Newtonsoft.Json",
|
50
50
|
"7.0.1",
|
51
|
-
|
51
|
+
"../packages"
|
52
52
|
];
|
53
53
|
|
54
54
|
// project with non-standard packages path
|
@@ -66,7 +66,7 @@ public class PackagesConfigUpdaterTests : TestBase
|
|
66
66
|
""",
|
67
67
|
"Newtonsoft.Json",
|
68
68
|
"7.0.1",
|
69
|
-
|
69
|
+
"../not-a-path-you-would-expect"
|
70
70
|
];
|
71
71
|
}
|
72
72
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
using NuGetUpdater.Core.Test.Updater;
|
1
2
|
using NuGetUpdater.Core.Updater;
|
2
3
|
|
3
4
|
using Xunit;
|
@@ -91,7 +92,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
91
92
|
TestFile[]? additionalFilesExpected = null,
|
92
93
|
MockNuGetPackage[]? packages = null,
|
93
94
|
string projectFilePath = "test-project.csproj",
|
94
|
-
|
95
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
95
96
|
=> TestUpdateForProject(
|
96
97
|
dependencyName,
|
97
98
|
oldVersion,
|
@@ -114,7 +115,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
114
115
|
TestFile[]? additionalFiles = null,
|
115
116
|
TestFile[]? additionalFilesExpected = null,
|
116
117
|
MockNuGetPackage[]? packages = null,
|
117
|
-
|
118
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
118
119
|
{
|
119
120
|
additionalFiles ??= [];
|
120
121
|
additionalFilesExpected ??= [];
|
@@ -133,7 +134,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
133
134
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
134
135
|
|
135
136
|
// run update
|
136
|
-
var worker = new UpdaterWorker(new
|
137
|
+
var worker = new UpdaterWorker(new TestLogger());
|
137
138
|
var projectPath = placeFilesInSrc ? $"src/{projectFilePath}" : projectFilePath;
|
138
139
|
var actualResult = await worker.RunWithErrorHandlingAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
|
139
140
|
if (expectedResult is { })
|
@@ -151,10 +152,17 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
151
152
|
AssertContainsFiles(expectedResultFiles, actualResult);
|
152
153
|
}
|
153
154
|
|
154
|
-
protected static void ValidateUpdateOperationResult(
|
155
|
+
protected static void ValidateUpdateOperationResult(ExpectedUpdateOperationResult expectedResult, UpdateOperationResult actualResult)
|
155
156
|
{
|
156
157
|
Assert.Equal(expectedResult.ErrorType, actualResult.ErrorType);
|
157
|
-
|
158
|
+
if (expectedResult.ErrorDetailsRegex is not null && actualResult.ErrorDetails is string errorDetails)
|
159
|
+
{
|
160
|
+
Assert.Matches(expectedResult.ErrorDetailsRegex, errorDetails);
|
161
|
+
}
|
162
|
+
else
|
163
|
+
{
|
164
|
+
Assert.Equivalent(expectedResult.ErrorDetails, actualResult.ErrorDetails);
|
165
|
+
}
|
158
166
|
}
|
159
167
|
|
160
168
|
protected static Task TestNoChangeforSolution(
|
@@ -229,7 +237,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
229
237
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
230
238
|
|
231
239
|
var slnPath = Path.Combine(temporaryDirectory, slnName);
|
232
|
-
var worker = new UpdaterWorker(new
|
240
|
+
var worker = new UpdaterWorker(new TestLogger());
|
233
241
|
await worker.RunAsync(temporaryDirectory, slnPath, dependencyName, oldVersion, newVersion, isTransitive);
|
234
242
|
});
|
235
243
|
|
@@ -364,7 +364,7 @@ public partial class UpdateWorkerTests
|
|
364
364
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
365
365
|
|
366
366
|
var projectPath = Path.Combine(temporaryDirectory, projectFileName);
|
367
|
-
var worker = new UpdaterWorker(new
|
367
|
+
var worker = new UpdaterWorker(new TestLogger());
|
368
368
|
await worker.RunAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
|
369
369
|
});
|
370
370
|
|
@@ -20,7 +20,7 @@ public partial class UpdateWorkerTests
|
|
20
20
|
ErrorDetails = "<some package feed>",
|
21
21
|
};
|
22
22
|
var resultFilePath = Path.Combine(temporaryDirectory.DirectoryPath, "update-result.json");
|
23
|
-
await UpdaterWorker.WriteResultFile(result, resultFilePath, new
|
23
|
+
await UpdaterWorker.WriteResultFile(result, resultFilePath, new TestLogger());
|
24
24
|
var resultContent = await File.ReadAllTextAsync(resultFilePath);
|
25
25
|
|
26
26
|
// raw result file should look like this:
|