dependabot-nuget 0.321.2 → 0.322.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 +22 -22
- data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation/Model/PackageMapper.cs +9 -0
- data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation.Cli/Program.cs +21 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +19 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/CloneCommand.cs +19 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +21 -14
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +8 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +29 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +20 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscoveryTargetingPacks.props +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/IDependencySolver.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +32 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +10 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +5 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/PrivateSourceTimedOutException.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +4 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceTimedOut.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +1 -1
- 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/DotNetToolsJsonUpdater.cs +6 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +376 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/IFileWriter.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +477 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +18 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +26 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +633 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +49 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +484 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/JobErrorBaseTests.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +21 -22
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/DotNetToolsJsonUpdaterTests.cs +181 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterTestsBase.cs +61 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +917 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests_MiscellaneousTests.cs +154 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/TestFileWriterReturnsConstantResult.cs +20 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +1620 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests_CreateUpdatedVersionRangeTests.cs +25 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/GlobalJsonUpdaterTests.cs +139 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +1961 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationResultTests.cs +116 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +16 -1043
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- metadata +21 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +0 -375
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +0 -296
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.LockFile.cs +0 -251
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +0 -201
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +0 -3821
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +0 -2706
@@ -79,7 +79,7 @@ public class PullRequestTextTests
|
|
79
79
|
// expectedBody
|
80
80
|
"""
|
81
81
|
Performed the following updates:
|
82
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
82
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
83
83
|
"""
|
84
84
|
];
|
85
85
|
|
@@ -108,7 +108,7 @@ public class PullRequestTextTests
|
|
108
108
|
// expectedBody
|
109
109
|
"""
|
110
110
|
Performed the following updates:
|
111
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
111
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
112
112
|
"""
|
113
113
|
];
|
114
114
|
|
@@ -137,7 +137,7 @@ public class PullRequestTextTests
|
|
137
137
|
// expectedBody
|
138
138
|
"""
|
139
139
|
Performed the following updates:
|
140
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
140
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
141
141
|
"""
|
142
142
|
];
|
143
143
|
|
@@ -173,8 +173,8 @@ public class PullRequestTextTests
|
|
173
173
|
// expectedBody
|
174
174
|
"""
|
175
175
|
Performed the following updates:
|
176
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
177
|
-
- Updated Some.Package from 4.0.0 to 4.5.6
|
176
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
177
|
+
- Updated Some.Package from 4.0.0 to 4.5.6
|
178
178
|
"""
|
179
179
|
];
|
180
180
|
|
@@ -229,10 +229,10 @@ public class PullRequestTextTests
|
|
229
229
|
// expectedBody
|
230
230
|
"""
|
231
231
|
Performed the following updates:
|
232
|
-
- Updated Package.A from 0.1.0 to 1.0.0
|
233
|
-
- Updated Package.A from 0.2.0 to 2.0.0
|
234
|
-
- Updated Package.B from 0.3.0 to 3.0.0
|
235
|
-
- Updated Package.B from 0.4.0 to 4.0.0
|
232
|
+
- Updated Package.A from 0.1.0 to 1.0.0
|
233
|
+
- Updated Package.A from 0.2.0 to 2.0.0
|
234
|
+
- Updated Package.B from 0.3.0 to 3.0.0
|
235
|
+
- Updated Package.B from 0.4.0 to 4.0.0
|
236
236
|
"""
|
237
237
|
];
|
238
238
|
|
@@ -317,14 +317,14 @@ public class PullRequestTextTests
|
|
317
317
|
// expectedBody
|
318
318
|
"""
|
319
319
|
Performed the following updates:
|
320
|
-
- Updated Package.A from 0.1.0 to 1.0.0
|
321
|
-
- Updated Package.A from 0.2.0 to 2.0.0
|
322
|
-
- Updated Package.B from 0.3.0 to 3.0.0
|
323
|
-
- Updated Package.B from 0.4.0 to 4.0.0
|
324
|
-
- Updated Package.C from 0.5.0 to 5.0.0
|
325
|
-
- Updated Package.C from 0.6.0 to 6.0.0
|
326
|
-
- Updated Package.D from 0.7.0 to 7.0.0
|
327
|
-
- Updated Package.D from 0.8.0 to 8.0.0
|
320
|
+
- Updated Package.A from 0.1.0 to 1.0.0
|
321
|
+
- Updated Package.A from 0.2.0 to 2.0.0
|
322
|
+
- Updated Package.B from 0.3.0 to 3.0.0
|
323
|
+
- Updated Package.B from 0.4.0 to 4.0.0
|
324
|
+
- Updated Package.C from 0.5.0 to 5.0.0
|
325
|
+
- Updated Package.C from 0.6.0 to 6.0.0
|
326
|
+
- Updated Package.D from 0.7.0 to 7.0.0
|
327
|
+
- Updated Package.D from 0.8.0 to 8.0.0
|
328
328
|
"""
|
329
329
|
];
|
330
330
|
|
@@ -357,7 +357,7 @@ public class PullRequestTextTests
|
|
357
357
|
// expectedBody
|
358
358
|
"""
|
359
359
|
Performed the following updates:
|
360
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
360
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
361
361
|
"""
|
362
362
|
];
|
363
363
|
|
@@ -398,8 +398,8 @@ public class PullRequestTextTests
|
|
398
398
|
// expectedBody
|
399
399
|
"""
|
400
400
|
Performed the following updates:
|
401
|
-
- Updated Package.A from 1.0.0 to 1.2.3
|
402
|
-
- Updated Package.B from 4.0.0 to 4.5.6
|
401
|
+
- Updated Package.A from 1.0.0 to 1.2.3
|
402
|
+
- Updated Package.B from 4.0.0 to 4.5.6
|
403
403
|
"""
|
404
404
|
];
|
405
405
|
|
@@ -437,8 +437,7 @@ public class PullRequestTextTests
|
|
437
437
|
// expectedBody
|
438
438
|
"""
|
439
439
|
Performed the following updates:
|
440
|
-
- Updated Some.Package from 1.0.0 to 1.2.3
|
441
|
-
- Updated Some.Package from 1.0.0 to 1.2.3 in b.txt
|
440
|
+
- Updated Some.Package from 1.0.0 to 1.2.3
|
442
441
|
"""
|
443
442
|
];
|
444
443
|
}
|
@@ -3522,7 +3522,7 @@ public class RunWorkerTests
|
|
3522
3522
|
updaterWorker ??= new UpdaterWorker(jobId, experimentsManager, logger);
|
3523
3523
|
|
3524
3524
|
var worker = new RunWorker(jobId, testApiHandler, discoveryWorker, analyzeWorker, updaterWorker, logger);
|
3525
|
-
var repoContentsPathDirectoryInfo = new DirectoryInfo(
|
3525
|
+
var repoContentsPathDirectoryInfo = new DirectoryInfo(repoContentsPath);
|
3526
3526
|
var actualResult = await worker.RunAsync(job, repoContentsPathDirectoryInfo, repoContentsPathDirectoryInfo, "TEST-COMMIT-SHA", experimentsManager);
|
3527
3527
|
var actualApiMessages = testApiHandler.ReceivedMessages
|
3528
3528
|
.Select(m =>
|
@@ -707,6 +707,14 @@ public class SerializationTests : TestBase
|
|
707
707
|
"""
|
708
708
|
];
|
709
709
|
|
710
|
+
yield return
|
711
|
+
[
|
712
|
+
new PrivateSourceTimedOut("url"),
|
713
|
+
"""
|
714
|
+
{"data":{"error-type":"private_source_timed_out","error-details":{"source":"url"}}}
|
715
|
+
"""
|
716
|
+
];
|
717
|
+
|
710
718
|
yield return
|
711
719
|
[
|
712
720
|
new PullRequestExistsForLatestVersion("dep", "ver"),
|
@@ -0,0 +1,181 @@
|
|
1
|
+
using Xunit;
|
2
|
+
|
3
|
+
namespace NuGetUpdater.Core.Test.Update;
|
4
|
+
|
5
|
+
public class DotNetToolsJsonUpdaterTests
|
6
|
+
{
|
7
|
+
[Fact]
|
8
|
+
public async Task UpdateDependency_MaintainComments()
|
9
|
+
{
|
10
|
+
await TestAsync(
|
11
|
+
dotnetToolsContent: """
|
12
|
+
{
|
13
|
+
// this is a comment
|
14
|
+
"version": 1,
|
15
|
+
"isRoot": true,
|
16
|
+
"tools": {
|
17
|
+
"some.dotnet.tool": {
|
18
|
+
// this is a deep comment
|
19
|
+
"version": "1.0.0",
|
20
|
+
"commands": [
|
21
|
+
"some.dotnet.tool"
|
22
|
+
]
|
23
|
+
},
|
24
|
+
"some-other-tool": {
|
25
|
+
"version": "2.1.3",
|
26
|
+
"commands": [
|
27
|
+
"some-other-tool"
|
28
|
+
]
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
""",
|
33
|
+
dependencyName: "Some.DotNet.Tool",
|
34
|
+
previousDependencyVersion: "1.0.0",
|
35
|
+
newDependencyVersion: "1.1.0",
|
36
|
+
expectedUpdatedDotnetToolsContent: """
|
37
|
+
{
|
38
|
+
// this is a comment
|
39
|
+
"version": 1,
|
40
|
+
"isRoot": true,
|
41
|
+
"tools": {
|
42
|
+
"some.dotnet.tool": {
|
43
|
+
// this is a deep comment
|
44
|
+
"version": "1.1.0",
|
45
|
+
"commands": [
|
46
|
+
"some.dotnet.tool"
|
47
|
+
]
|
48
|
+
},
|
49
|
+
"some-other-tool": {
|
50
|
+
"version": "2.1.3",
|
51
|
+
"commands": [
|
52
|
+
"some-other-tool"
|
53
|
+
]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
"""
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
[Fact]
|
62
|
+
public async Task UpdateDependency_TrailingCommaInOriginal()
|
63
|
+
{
|
64
|
+
await TestAsync(
|
65
|
+
dotnetToolsContent: """
|
66
|
+
{
|
67
|
+
"version": 1,
|
68
|
+
"isRoot": true,
|
69
|
+
"tools": {
|
70
|
+
"some.dotnet.tool": {
|
71
|
+
"version": "1.0.0",
|
72
|
+
"commands": [
|
73
|
+
"some.dotnet.tool"
|
74
|
+
],
|
75
|
+
},
|
76
|
+
"some-other-tool": {
|
77
|
+
"version": "2.1.3",
|
78
|
+
"commands": [
|
79
|
+
"some-other-tool"
|
80
|
+
],
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
""",
|
85
|
+
dependencyName: "Some.DotNet.Tool",
|
86
|
+
previousDependencyVersion: "1.0.0",
|
87
|
+
newDependencyVersion: "1.1.0",
|
88
|
+
expectedUpdatedDotnetToolsContent: """
|
89
|
+
{
|
90
|
+
"version": 1,
|
91
|
+
"isRoot": true,
|
92
|
+
"tools": {
|
93
|
+
"some.dotnet.tool": {
|
94
|
+
"version": "1.1.0",
|
95
|
+
"commands": [
|
96
|
+
"some.dotnet.tool"
|
97
|
+
]
|
98
|
+
},
|
99
|
+
"some-other-tool": {
|
100
|
+
"version": "2.1.3",
|
101
|
+
"commands": [
|
102
|
+
"some-other-tool"
|
103
|
+
]
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
"""
|
108
|
+
);
|
109
|
+
}
|
110
|
+
|
111
|
+
[Fact]
|
112
|
+
public async Task MissingDependency_NoUpdatePerformed()
|
113
|
+
{
|
114
|
+
await TestAsync(
|
115
|
+
dotnetToolsContent: """
|
116
|
+
{
|
117
|
+
"version": 1,
|
118
|
+
"isRoot": true,
|
119
|
+
"tools": {
|
120
|
+
"some-other-tool": {
|
121
|
+
"version": "2.1.3",
|
122
|
+
"commands": [
|
123
|
+
"some-other-tool"
|
124
|
+
]
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
""",
|
129
|
+
dependencyName: "Some.DotNet.Tool",
|
130
|
+
previousDependencyVersion: "1.0.0",
|
131
|
+
newDependencyVersion: "1.1.0",
|
132
|
+
expectedUpdatedDotnetToolsContent: """
|
133
|
+
{
|
134
|
+
"version": 1,
|
135
|
+
"isRoot": true,
|
136
|
+
"tools": {
|
137
|
+
"some-other-tool": {
|
138
|
+
"version": "2.1.3",
|
139
|
+
"commands": [
|
140
|
+
"some-other-tool"
|
141
|
+
]
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
"""
|
146
|
+
);
|
147
|
+
}
|
148
|
+
|
149
|
+
private async Task TestAsync(
|
150
|
+
string dotnetToolsContent,
|
151
|
+
string dependencyName,
|
152
|
+
string previousDependencyVersion,
|
153
|
+
string newDependencyVersion,
|
154
|
+
string expectedUpdatedDotnetToolsContent,
|
155
|
+
string workspaceDirectory = "/",
|
156
|
+
string dotnetToolsJsonPath = ".config/dotnet-tools.json"
|
157
|
+
)
|
158
|
+
{
|
159
|
+
// arrange
|
160
|
+
using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(
|
161
|
+
(dotnetToolsJsonPath, dotnetToolsContent)
|
162
|
+
);
|
163
|
+
var logger = new TestLogger();
|
164
|
+
|
165
|
+
// act
|
166
|
+
var updatedFilePath = await DotNetToolsJsonUpdater.UpdateDependencyAsync(tempDir.DirectoryPath, workspaceDirectory, dependencyName, previousDependencyVersion, newDependencyVersion, logger);
|
167
|
+
|
168
|
+
// assert
|
169
|
+
var expectedUpdateToHappen = dotnetToolsContent.Replace("\r", "") != expectedUpdatedDotnetToolsContent.Replace("\r", "");
|
170
|
+
if (expectedUpdateToHappen)
|
171
|
+
{
|
172
|
+
Assert.NotNull(updatedFilePath);
|
173
|
+
var relativeUpdatedFilePath = Path.GetRelativePath(tempDir.DirectoryPath, updatedFilePath).NormalizePathToUnix();
|
174
|
+
Assert.Equal(dotnetToolsJsonPath, relativeUpdatedFilePath);
|
175
|
+
}
|
176
|
+
|
177
|
+
var actualFileContents = await tempDir.ReadFileContentsAsync([dotnetToolsJsonPath]);
|
178
|
+
var actualContent = actualFileContents.Single().Contents.Replace("\r", "");
|
179
|
+
Assert.Equal(expectedUpdatedDotnetToolsContent.Replace("\r", ""), actualContent);
|
180
|
+
}
|
181
|
+
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterTestsBase.cs
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
using System.Collections.Immutable;
|
2
|
+
|
3
|
+
using NuGetUpdater.Core.Updater.FileWriters;
|
4
|
+
|
5
|
+
using Xunit;
|
6
|
+
|
7
|
+
namespace NuGetUpdater.Core.Test.Update.FileWriters;
|
8
|
+
|
9
|
+
public abstract class FileWriterTestsBase
|
10
|
+
{
|
11
|
+
public abstract IFileWriter FileWriter { get; }
|
12
|
+
|
13
|
+
protected async Task TestAsync(
|
14
|
+
(string path, string contents)[] files,
|
15
|
+
ImmutableArray<string> initialProjectDependencyStrings,
|
16
|
+
ImmutableArray<string> requiredDependencyStrings,
|
17
|
+
(string path, string contents)[] expectedFiles,
|
18
|
+
bool useCentralPackageTransitivePinning = false
|
19
|
+
)
|
20
|
+
{
|
21
|
+
using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(files);
|
22
|
+
var repoContentsPath = new DirectoryInfo(tempDir.DirectoryPath);
|
23
|
+
var initialProjectDependencies = initialProjectDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
|
24
|
+
var requiredDependencies = requiredDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
|
25
|
+
var addPackageReferenceElementForPinnedPackages = !useCentralPackageTransitivePinning;
|
26
|
+
var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, addPackageReferenceElementForPinnedPackages);
|
27
|
+
Assert.True(success);
|
28
|
+
|
29
|
+
var expectedFileNames = expectedFiles.Select(f => f.path).ToHashSet();
|
30
|
+
var actualFiles = (await tempDir.ReadFileContentsAsync(expectedFileNames)).ToDictionary(f => f.Path, f => f.Contents);
|
31
|
+
foreach (var (expectedPath, expectedContents) in expectedFiles)
|
32
|
+
{
|
33
|
+
Assert.True(actualFiles.TryGetValue(expectedPath, out var actualContents), $"Expected file {expectedPath} not found.");
|
34
|
+
Assert.Equal(expectedContents.Replace("\r", ""), actualContents.Replace("\r", ""));
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
protected async Task TestNoChangeAsync(
|
39
|
+
(string path, string contents)[] files,
|
40
|
+
ImmutableArray<string> initialProjectDependencyStrings,
|
41
|
+
ImmutableArray<string> requiredDependencyStrings,
|
42
|
+
bool useCentralPackageTransitivePinning = false
|
43
|
+
)
|
44
|
+
{
|
45
|
+
using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(files);
|
46
|
+
var repoContentsPath = new DirectoryInfo(tempDir.DirectoryPath);
|
47
|
+
var initialProjectDependencies = initialProjectDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
|
48
|
+
var requiredDependencies = requiredDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
|
49
|
+
var addPackageReferenceElementForPinnedPackages = !useCentralPackageTransitivePinning;
|
50
|
+
var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, addPackageReferenceElementForPinnedPackages);
|
51
|
+
Assert.False(success);
|
52
|
+
|
53
|
+
var expectedFileNames = files.Select(f => f.path).ToHashSet();
|
54
|
+
var actualFiles = (await tempDir.ReadFileContentsAsync(expectedFileNames)).ToDictionary(f => f.Path, f => f.Contents);
|
55
|
+
foreach (var (expectedPath, expectedContents) in files)
|
56
|
+
{
|
57
|
+
Assert.True(actualFiles.TryGetValue(expectedPath, out var actualContents), $"Expected file {expectedPath} not found.");
|
58
|
+
Assert.Equal(expectedContents.Replace("\r", ""), actualContents.Replace("\r", ""));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|