dependabot-nuget 0.309.0 → 0.311.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 +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +1 -1
- 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 +19 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/MessageBase.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdatePullRequest.cs +16 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/HttpApiHandler.cs +12 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +49 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +31 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +6 -33
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +12 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +2 -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/EndToEndTests.cs +355 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +232 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +32 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1212 -840
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +4 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestHttpServer.cs +16 -6
- 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/EOLHandlingTests.cs +227 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LoggerTests.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +382 -165
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- metadata +11 -9
@@ -0,0 +1,355 @@
|
|
1
|
+
using System.Text;
|
2
|
+
|
3
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
4
|
+
using NuGetUpdater.Core.Run;
|
5
|
+
using Xunit;
|
6
|
+
using NuGetUpdater.Core.Analyze;
|
7
|
+
|
8
|
+
namespace NuGetUpdater.Core.Test.Run;
|
9
|
+
|
10
|
+
public class EndToEndTests
|
11
|
+
{
|
12
|
+
[Fact]
|
13
|
+
public async Task UpdatePackageWithDifferentVersionsInDifferentDirectories()
|
14
|
+
{
|
15
|
+
// this test passes `null` for discovery, analyze, and update workers to fully test the desired behavior
|
16
|
+
|
17
|
+
// the same dependency Some.Package is reported for 3 cases:
|
18
|
+
// library1.csproj - top level dependency, already up to date
|
19
|
+
// library2.csproj - top level dependency, needs direct update
|
20
|
+
// library3.csproj - transitive dependency, needs pin
|
21
|
+
await RunWorkerTests.RunAsync(
|
22
|
+
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true },
|
23
|
+
packages: [
|
24
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
25
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
26
|
+
MockNuGetPackage.CreateSimplePackage("Package.With.Transitive.Dependency", "0.1.0", "net8.0", [(null, [("Some.Package", "1.0.0")])]),
|
27
|
+
],
|
28
|
+
job: new Job()
|
29
|
+
{
|
30
|
+
AllowedUpdates = [new() { UpdateType = UpdateType.Security }],
|
31
|
+
SecurityAdvisories =
|
32
|
+
[
|
33
|
+
new()
|
34
|
+
{
|
35
|
+
DependencyName = "Some.Package",
|
36
|
+
AffectedVersions = [Requirement.Parse("= 1.0.0")]
|
37
|
+
}
|
38
|
+
],
|
39
|
+
Source = new()
|
40
|
+
{
|
41
|
+
Provider = "github",
|
42
|
+
Repo = "test/repo",
|
43
|
+
Directory = "/"
|
44
|
+
}
|
45
|
+
},
|
46
|
+
files: [
|
47
|
+
("dirs.proj", """
|
48
|
+
<Project>
|
49
|
+
<ItemGroup>
|
50
|
+
<ProjectFile Include="library1\library1.csproj" />
|
51
|
+
<ProjectFile Include="library2\library2.csproj" />
|
52
|
+
<ProjectFile Include="library3\library3.csproj" />
|
53
|
+
</ItemGroup>
|
54
|
+
</Project>
|
55
|
+
"""),
|
56
|
+
("Directory.Build.props", "<Project />"),
|
57
|
+
("Directory.Build.targets", "<Project />"),
|
58
|
+
("Directory.Packages.props", """
|
59
|
+
<Project>
|
60
|
+
<PropertyGroup>
|
61
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
62
|
+
</PropertyGroup>
|
63
|
+
</Project>
|
64
|
+
"""),
|
65
|
+
("library1/library1.csproj", """
|
66
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
67
|
+
<PropertyGroup>
|
68
|
+
<TargetFramework>net8.0</TargetFramework>
|
69
|
+
</PropertyGroup>
|
70
|
+
<ItemGroup>
|
71
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
72
|
+
</ItemGroup>
|
73
|
+
</Project>
|
74
|
+
"""),
|
75
|
+
("library2/library2.csproj", """
|
76
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
77
|
+
<PropertyGroup>
|
78
|
+
<TargetFramework>net8.0</TargetFramework>
|
79
|
+
</PropertyGroup>
|
80
|
+
<ItemGroup>
|
81
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
82
|
+
</ItemGroup>
|
83
|
+
</Project>
|
84
|
+
"""),
|
85
|
+
("library3/library3.csproj", """
|
86
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
87
|
+
<PropertyGroup>
|
88
|
+
<TargetFramework>net8.0</TargetFramework>
|
89
|
+
</PropertyGroup>
|
90
|
+
<ItemGroup>
|
91
|
+
<PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
|
92
|
+
</ItemGroup>
|
93
|
+
</Project>
|
94
|
+
"""),
|
95
|
+
],
|
96
|
+
discoveryWorker: null,
|
97
|
+
analyzeWorker: null,
|
98
|
+
updaterWorker: null,
|
99
|
+
expectedResult: new RunResult()
|
100
|
+
{
|
101
|
+
Base64DependencyFiles =
|
102
|
+
[
|
103
|
+
new DependencyFile()
|
104
|
+
{
|
105
|
+
Directory = "/",
|
106
|
+
Name = "Directory.Build.props",
|
107
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
|
108
|
+
ContentEncoding = "base64",
|
109
|
+
},
|
110
|
+
new DependencyFile()
|
111
|
+
{
|
112
|
+
Directory = "/",
|
113
|
+
Name = "Directory.Build.targets",
|
114
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("<Project />")),
|
115
|
+
ContentEncoding = "base64",
|
116
|
+
},
|
117
|
+
new DependencyFile()
|
118
|
+
{
|
119
|
+
Directory = "/",
|
120
|
+
Name = "Directory.Packages.props",
|
121
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
122
|
+
<Project>
|
123
|
+
<PropertyGroup>
|
124
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
125
|
+
</PropertyGroup>
|
126
|
+
</Project>
|
127
|
+
""")),
|
128
|
+
ContentEncoding = "base64",
|
129
|
+
},
|
130
|
+
new DependencyFile()
|
131
|
+
{
|
132
|
+
Directory = "/library1",
|
133
|
+
Name = "library1.csproj",
|
134
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
135
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
136
|
+
<PropertyGroup>
|
137
|
+
<TargetFramework>net8.0</TargetFramework>
|
138
|
+
</PropertyGroup>
|
139
|
+
<ItemGroup>
|
140
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
141
|
+
</ItemGroup>
|
142
|
+
</Project>
|
143
|
+
""")),
|
144
|
+
ContentEncoding = "base64",
|
145
|
+
},
|
146
|
+
new DependencyFile()
|
147
|
+
{
|
148
|
+
Directory = "/library2",
|
149
|
+
Name = "library2.csproj",
|
150
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
151
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
152
|
+
<PropertyGroup>
|
153
|
+
<TargetFramework>net8.0</TargetFramework>
|
154
|
+
</PropertyGroup>
|
155
|
+
<ItemGroup>
|
156
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
157
|
+
</ItemGroup>
|
158
|
+
</Project>
|
159
|
+
""")),
|
160
|
+
ContentEncoding = "base64",
|
161
|
+
},
|
162
|
+
new DependencyFile()
|
163
|
+
{
|
164
|
+
Directory = "/library3",
|
165
|
+
Name = "library3.csproj",
|
166
|
+
Content = Convert.ToBase64String(Encoding.UTF8.GetBytes("""
|
167
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
168
|
+
<PropertyGroup>
|
169
|
+
<TargetFramework>net8.0</TargetFramework>
|
170
|
+
</PropertyGroup>
|
171
|
+
<ItemGroup>
|
172
|
+
<PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
|
173
|
+
</ItemGroup>
|
174
|
+
</Project>
|
175
|
+
""")),
|
176
|
+
ContentEncoding = "base64",
|
177
|
+
}
|
178
|
+
],
|
179
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
180
|
+
},
|
181
|
+
expectedApiMessages: [
|
182
|
+
new UpdatedDependencyList()
|
183
|
+
{
|
184
|
+
Dependencies = [
|
185
|
+
new()
|
186
|
+
{
|
187
|
+
Name = "Some.Package",
|
188
|
+
Version = "2.0.0",
|
189
|
+
Requirements = [
|
190
|
+
new()
|
191
|
+
{
|
192
|
+
Requirement = "2.0.0",
|
193
|
+
File = "/library1/library1.csproj",
|
194
|
+
Groups = ["dependencies"],
|
195
|
+
}
|
196
|
+
]
|
197
|
+
},
|
198
|
+
new()
|
199
|
+
{
|
200
|
+
Name = "Some.Package",
|
201
|
+
Version = "1.0.0",
|
202
|
+
Requirements = [
|
203
|
+
new()
|
204
|
+
{
|
205
|
+
Requirement = "1.0.0",
|
206
|
+
File = "/library2/library2.csproj",
|
207
|
+
Groups = ["dependencies"],
|
208
|
+
}
|
209
|
+
]
|
210
|
+
},
|
211
|
+
new()
|
212
|
+
{
|
213
|
+
Name = "Package.With.Transitive.Dependency",
|
214
|
+
Version = "0.1.0",
|
215
|
+
Requirements = [
|
216
|
+
new()
|
217
|
+
{
|
218
|
+
Requirement = "0.1.0",
|
219
|
+
File = "/library3/library3.csproj",
|
220
|
+
Groups = ["dependencies"],
|
221
|
+
}
|
222
|
+
]
|
223
|
+
},
|
224
|
+
new()
|
225
|
+
{
|
226
|
+
Name = "Some.Package",
|
227
|
+
Version = "1.0.0",
|
228
|
+
Requirements = [
|
229
|
+
new()
|
230
|
+
{
|
231
|
+
Requirement = "1.0.0",
|
232
|
+
File = "/library3/library3.csproj",
|
233
|
+
Groups = ["dependencies"],
|
234
|
+
}
|
235
|
+
]
|
236
|
+
},
|
237
|
+
],
|
238
|
+
DependencyFiles = [
|
239
|
+
"/Directory.Build.props",
|
240
|
+
"/Directory.Build.targets",
|
241
|
+
"/Directory.Packages.props",
|
242
|
+
"/library1/library1.csproj",
|
243
|
+
"/library2/library2.csproj",
|
244
|
+
"/library3/library3.csproj",
|
245
|
+
],
|
246
|
+
},
|
247
|
+
new IncrementMetric()
|
248
|
+
{
|
249
|
+
Metric = "updater.started",
|
250
|
+
Tags = new()
|
251
|
+
{
|
252
|
+
["operation"] = "create_security_pr"
|
253
|
+
}
|
254
|
+
},
|
255
|
+
new CreatePullRequest()
|
256
|
+
{
|
257
|
+
Dependencies = [
|
258
|
+
new()
|
259
|
+
{
|
260
|
+
Name = "Some.Package",
|
261
|
+
Version = "2.0.0",
|
262
|
+
Requirements = [
|
263
|
+
new()
|
264
|
+
{
|
265
|
+
Requirement = "2.0.0",
|
266
|
+
File = "/library2/library2.csproj",
|
267
|
+
Groups = ["dependencies"],
|
268
|
+
Source = new()
|
269
|
+
{
|
270
|
+
SourceUrl = null,
|
271
|
+
Type = "nuget_repo",
|
272
|
+
}
|
273
|
+
}
|
274
|
+
],
|
275
|
+
PreviousVersion = "1.0.0",
|
276
|
+
PreviousRequirements = [
|
277
|
+
new()
|
278
|
+
{
|
279
|
+
Requirement = "1.0.0",
|
280
|
+
File = "/library2/library2.csproj",
|
281
|
+
Groups = ["dependencies"],
|
282
|
+
}
|
283
|
+
],
|
284
|
+
},
|
285
|
+
new()
|
286
|
+
{
|
287
|
+
Name = "Some.Package",
|
288
|
+
Version = "2.0.0",
|
289
|
+
Requirements = [
|
290
|
+
new()
|
291
|
+
{
|
292
|
+
Requirement = "2.0.0",
|
293
|
+
File = "/library3/library3.csproj",
|
294
|
+
Groups = ["dependencies"],
|
295
|
+
Source = new()
|
296
|
+
{
|
297
|
+
SourceUrl = null,
|
298
|
+
Type = "nuget_repo",
|
299
|
+
}
|
300
|
+
}
|
301
|
+
],
|
302
|
+
PreviousVersion = "1.0.0",
|
303
|
+
PreviousRequirements = [
|
304
|
+
new()
|
305
|
+
{
|
306
|
+
Requirement = "1.0.0",
|
307
|
+
File = "/library3/library3.csproj",
|
308
|
+
Groups = ["dependencies"],
|
309
|
+
}
|
310
|
+
],
|
311
|
+
},
|
312
|
+
],
|
313
|
+
UpdatedDependencyFiles = [
|
314
|
+
new()
|
315
|
+
{
|
316
|
+
Directory = "/library2",
|
317
|
+
Name = "library2.csproj",
|
318
|
+
Content = """
|
319
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
320
|
+
<PropertyGroup>
|
321
|
+
<TargetFramework>net8.0</TargetFramework>
|
322
|
+
</PropertyGroup>
|
323
|
+
<ItemGroup>
|
324
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
325
|
+
</ItemGroup>
|
326
|
+
</Project>
|
327
|
+
"""
|
328
|
+
},
|
329
|
+
new()
|
330
|
+
{
|
331
|
+
Directory = "/library3",
|
332
|
+
Name = "library3.csproj",
|
333
|
+
Content = """
|
334
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
335
|
+
<PropertyGroup>
|
336
|
+
<TargetFramework>net8.0</TargetFramework>
|
337
|
+
</PropertyGroup>
|
338
|
+
<ItemGroup>
|
339
|
+
<PackageReference Include="Package.With.Transitive.Dependency" Version="0.1.0" />
|
340
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
341
|
+
</ItemGroup>
|
342
|
+
</Project>
|
343
|
+
"""
|
344
|
+
}
|
345
|
+
],
|
346
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
347
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
348
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
349
|
+
PrBody = RunWorkerTests.TestPullRequestBody
|
350
|
+
},
|
351
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
352
|
+
]
|
353
|
+
);
|
354
|
+
}
|
355
|
+
}
|
@@ -0,0 +1,232 @@
|
|
1
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Run;
|
6
|
+
|
7
|
+
public class MessageReportTests
|
8
|
+
{
|
9
|
+
[Fact]
|
10
|
+
public void AllMessagesAreTested()
|
11
|
+
{
|
12
|
+
var untestedTypes = typeof(MessageBase).Assembly.GetTypes()
|
13
|
+
.Where(t => t.IsSubclassOf(typeof(MessageBase)))
|
14
|
+
.Where(t => t != typeof(JobErrorBase)) // this is an abstract class and can't be directly tested
|
15
|
+
.ToHashSet();
|
16
|
+
foreach (var data in MessageBaseTestData())
|
17
|
+
{
|
18
|
+
var testedMessageType = data[0]!.GetType();
|
19
|
+
untestedTypes.Remove(testedMessageType);
|
20
|
+
}
|
21
|
+
|
22
|
+
Assert.Empty(untestedTypes.Select(t => t.Name));
|
23
|
+
}
|
24
|
+
|
25
|
+
[Theory]
|
26
|
+
[MemberData(nameof(MessageBaseTestData))]
|
27
|
+
public void MessageBase(MessageBase message, string expected)
|
28
|
+
{
|
29
|
+
var actual = message.GetReport().Replace("\r", "");
|
30
|
+
Assert.Equal(expected.Replace("\r", ""), actual);
|
31
|
+
}
|
32
|
+
|
33
|
+
public static IEnumerable<object[]> MessageBaseTestData()
|
34
|
+
{
|
35
|
+
yield return
|
36
|
+
[
|
37
|
+
// message
|
38
|
+
new BadRequirement("unparseable"),
|
39
|
+
// expected
|
40
|
+
"""
|
41
|
+
Error type: illformed_requirement
|
42
|
+
- message: unparseable
|
43
|
+
"""
|
44
|
+
];
|
45
|
+
|
46
|
+
yield return
|
47
|
+
[
|
48
|
+
// message
|
49
|
+
new ClosePullRequest()
|
50
|
+
{
|
51
|
+
DependencyNames = ["Dependency1", "Dependency2"]
|
52
|
+
},
|
53
|
+
// expected
|
54
|
+
"""
|
55
|
+
ClosePullRequest: up_to_date
|
56
|
+
- Dependency1
|
57
|
+
- Dependency2
|
58
|
+
"""
|
59
|
+
];
|
60
|
+
|
61
|
+
yield return
|
62
|
+
[
|
63
|
+
// message
|
64
|
+
new CreatePullRequest()
|
65
|
+
{
|
66
|
+
Dependencies = [
|
67
|
+
new()
|
68
|
+
{
|
69
|
+
Name = "Dependency1",
|
70
|
+
Version = "1.2.3",
|
71
|
+
Requirements = [], // unused
|
72
|
+
},
|
73
|
+
new()
|
74
|
+
{
|
75
|
+
Name = "Dependency2",
|
76
|
+
Version = "4.5.6",
|
77
|
+
Requirements = [], // unused
|
78
|
+
}
|
79
|
+
],
|
80
|
+
UpdatedDependencyFiles = [], // unused
|
81
|
+
BaseCommitSha = "unused",
|
82
|
+
CommitMessage = "unused",
|
83
|
+
PrTitle = "unused",
|
84
|
+
PrBody = "unused",
|
85
|
+
},
|
86
|
+
// expected
|
87
|
+
"""
|
88
|
+
CreatePullRequest
|
89
|
+
- Dependency1/1.2.3
|
90
|
+
- Dependency2/4.5.6
|
91
|
+
"""
|
92
|
+
];
|
93
|
+
|
94
|
+
yield return
|
95
|
+
[
|
96
|
+
// message
|
97
|
+
new DependencyFileNotFound("path/to/file.txt", "custom message"),
|
98
|
+
// expected
|
99
|
+
"""
|
100
|
+
Error type: dependency_file_not_found
|
101
|
+
- message: custom message
|
102
|
+
- file-path: path/to/file.txt
|
103
|
+
"""
|
104
|
+
];
|
105
|
+
|
106
|
+
yield return
|
107
|
+
[
|
108
|
+
// message
|
109
|
+
new DependencyFileNotParseable("path/to/file.txt", "custom message"),
|
110
|
+
// expected
|
111
|
+
"""
|
112
|
+
Error type: dependency_file_not_parseable
|
113
|
+
- message: custom message
|
114
|
+
- file-path: path/to/file.txt
|
115
|
+
"""
|
116
|
+
];
|
117
|
+
|
118
|
+
yield return
|
119
|
+
[
|
120
|
+
// message
|
121
|
+
new DependencyNotFound("Some.Dependency"),
|
122
|
+
// expected
|
123
|
+
"""
|
124
|
+
Error type: dependency_not_found
|
125
|
+
- source: Some.Dependency
|
126
|
+
"""
|
127
|
+
];
|
128
|
+
|
129
|
+
yield return
|
130
|
+
[
|
131
|
+
// message
|
132
|
+
new JobRepoNotFound("custom message"),
|
133
|
+
// expected
|
134
|
+
"""
|
135
|
+
Error type: job_repo_not_found
|
136
|
+
- message: custom message
|
137
|
+
"""
|
138
|
+
];
|
139
|
+
|
140
|
+
yield return
|
141
|
+
[
|
142
|
+
// message
|
143
|
+
new PrivateSourceAuthenticationFailure(["url1", "url2"]),
|
144
|
+
// expected
|
145
|
+
"""
|
146
|
+
Error type: private_source_authentication_failure
|
147
|
+
- source: (url1|url2)
|
148
|
+
"""
|
149
|
+
];
|
150
|
+
|
151
|
+
yield return
|
152
|
+
[
|
153
|
+
// message
|
154
|
+
new PrivateSourceBadResponse(["url1", "url2"]),
|
155
|
+
// expected
|
156
|
+
"""
|
157
|
+
Error type: private_source_bad_response
|
158
|
+
- source: (url1|url2)
|
159
|
+
"""
|
160
|
+
];
|
161
|
+
|
162
|
+
yield return
|
163
|
+
[
|
164
|
+
// message
|
165
|
+
new PullRequestExistsForLatestVersion("Some.Dependency", "1.2.3"),
|
166
|
+
// expected
|
167
|
+
"""
|
168
|
+
Error type: pull_request_exists_for_latest_version
|
169
|
+
- dependency-name: Some.Dependency
|
170
|
+
- dependency-version: 1.2.3
|
171
|
+
"""
|
172
|
+
];
|
173
|
+
|
174
|
+
yield return
|
175
|
+
[
|
176
|
+
// message
|
177
|
+
new SecurityUpdateNotNeeded("Some.Dependency"),
|
178
|
+
// expected
|
179
|
+
"""
|
180
|
+
Error type: security_update_not_needed
|
181
|
+
- dependency-name: Some.Dependency
|
182
|
+
"""
|
183
|
+
];
|
184
|
+
|
185
|
+
yield return
|
186
|
+
[
|
187
|
+
// message
|
188
|
+
new UnknownError(new NotImplementedException("error message"), "TEST-JOB-ID"),
|
189
|
+
// expected
|
190
|
+
"""
|
191
|
+
Error type: unknown_error
|
192
|
+
- error-class: NotImplementedException
|
193
|
+
- error-message: error message
|
194
|
+
- error-backtrace: <unknown>
|
195
|
+
- package-manager: nuget
|
196
|
+
- job-id: TEST-JOB-ID
|
197
|
+
"""
|
198
|
+
];
|
199
|
+
|
200
|
+
yield return
|
201
|
+
[
|
202
|
+
// message
|
203
|
+
new UpdateNotPossible(["Dependency1", "Dependency2"]),
|
204
|
+
// expected
|
205
|
+
"""
|
206
|
+
Error type: update_not_possible
|
207
|
+
- dependencies: Dependency1, Dependency2
|
208
|
+
"""
|
209
|
+
];
|
210
|
+
|
211
|
+
yield return
|
212
|
+
[
|
213
|
+
// message
|
214
|
+
new UpdatePullRequest()
|
215
|
+
{
|
216
|
+
DependencyNames = ["Dependency1", "Dependency2"],
|
217
|
+
UpdatedDependencyFiles = [], // unused
|
218
|
+
BaseCommitSha = "unused",
|
219
|
+
CommitMessage = "unused",
|
220
|
+
PrTitle = "unused",
|
221
|
+
PrBody = "unused",
|
222
|
+
DependencyGroup = "unused",
|
223
|
+
},
|
224
|
+
// expected
|
225
|
+
"""
|
226
|
+
UpdatePullRequest
|
227
|
+
- Dependency1
|
228
|
+
- Dependency2
|
229
|
+
"""
|
230
|
+
];
|
231
|
+
}
|
232
|
+
}
|
@@ -12,6 +12,26 @@ namespace NuGetUpdater.Core.Test.Run;
|
|
12
12
|
|
13
13
|
public class PullRequestTextTests
|
14
14
|
{
|
15
|
+
[Fact]
|
16
|
+
public void LongPullRequestTitleIsTrimmed()
|
17
|
+
{
|
18
|
+
var job = FromCommitOptions(null);
|
19
|
+
var updateOperations = new List<UpdateOperationBase>();
|
20
|
+
for (int i = 1; i <= 10; i++)
|
21
|
+
{
|
22
|
+
updateOperations.Add(new DirectUpdate()
|
23
|
+
{
|
24
|
+
DependencyName = $"Package{i}",
|
25
|
+
NewVersion = NuGetVersion.Parse($"{i}.0.0"),
|
26
|
+
UpdatedFiles = ["file.txt"],
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
var actualTitle = PullRequestTextGenerator.GetPullRequestTitle(job, [.. updateOperations], dependencyGroupName: null);
|
31
|
+
var expectedTitle = "Update Package1 and 9 other dependencies";
|
32
|
+
Assert.Equal(expectedTitle, actualTitle);
|
33
|
+
}
|
34
|
+
|
15
35
|
[Theory]
|
16
36
|
[MemberData(nameof(GetPullRequestTextTestData))]
|
17
37
|
public void PullRequestText(
|
@@ -58,7 +78,7 @@ public class PullRequestTextTests
|
|
58
78
|
// expectedBody
|
59
79
|
"""
|
60
80
|
Performed the following updates:
|
61
|
-
|
81
|
+
- Updated Some.Package to 1.2.3 in a.txt
|
62
82
|
"""
|
63
83
|
];
|
64
84
|
|
@@ -82,11 +102,11 @@ public class PullRequestTextTests
|
|
82
102
|
// expectedTitle
|
83
103
|
"[SECURITY] Update Some.Package to 1.2.3",
|
84
104
|
// expectedCommitMessage
|
85
|
-
"
|
105
|
+
"Update Some.Package to 1.2.3",
|
86
106
|
// expectedBody
|
87
107
|
"""
|
88
108
|
Performed the following updates:
|
89
|
-
|
109
|
+
- Updated Some.Package to 1.2.3 in a.txt
|
90
110
|
"""
|
91
111
|
];
|
92
112
|
|
@@ -128,14 +148,18 @@ public class PullRequestTextTests
|
|
128
148
|
// expectedTitle
|
129
149
|
"Update Package.A to 1.0.0, 2.0.0; Package.B to 3.0.0, 4.0.0",
|
130
150
|
// expectedCommitMessage
|
131
|
-
"
|
151
|
+
"""
|
152
|
+
Update:
|
153
|
+
- Package.A to 1.0.0, 2.0.0
|
154
|
+
- Package.B to 3.0.0, 4.0.0
|
155
|
+
""",
|
132
156
|
// expectedBody
|
133
157
|
"""
|
134
158
|
Performed the following updates:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
159
|
+
- Updated Package.A to 1.0.0 in a1.txt
|
160
|
+
- Updated Package.A to 2.0.0 in a2.txt
|
161
|
+
- Updated Package.B to 3.0.0 in b1.txt
|
162
|
+
- Updated Package.B to 4.0.0 in b2.txt
|
139
163
|
"""
|
140
164
|
];
|
141
165
|
}
|