dependabot-nuget 0.302.0 → 0.304.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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +5 -5
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscoveryTargetingPacks.props +10 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +96 -97
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +2 -0
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -0
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +1 -0
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +1 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceBadResponse.cs +10 -0
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +8 -0
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +7 -4
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +257 -37
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -3
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +209 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationResult.cs +3 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +79 -24
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +25 -11
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +19 -5
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +77 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +24 -6
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +8 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +177 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationBaseTests.cs +130 -0
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +5 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +71 -5
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +87 -3
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +23 -0
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +145 -147
  30. data/lib/dependabot/nuget/native_helpers.rb +2 -0
  31. metadata +12 -7
@@ -1247,6 +1247,83 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1247
1247
  );
1248
1248
  }
1249
1249
 
1250
+ [Fact]
1251
+ public async Task ReportsPrivateSourceBadResponseFailure()
1252
+ {
1253
+ static (int, string) TestHttpHandler(string uriString)
1254
+ {
1255
+ var uri = new Uri(uriString, UriKind.Absolute);
1256
+ var baseUrl = $"{uri.Scheme}://{uri.Host}:{uri.Port}";
1257
+ return uri.PathAndQuery switch
1258
+ {
1259
+ // initial request is good
1260
+ "/index.json" => (200, $$"""
1261
+ {
1262
+ "version": "3.0.0",
1263
+ "resources": [
1264
+ {
1265
+ "@id": "{{baseUrl}}/download",
1266
+ "@type": "PackageBaseAddress/3.0.0"
1267
+ },
1268
+ {
1269
+ "@id": "{{baseUrl}}/query",
1270
+ "@type": "SearchQueryService"
1271
+ },
1272
+ {
1273
+ "@id": "{{baseUrl}}/registrations",
1274
+ "@type": "RegistrationsBaseUrl"
1275
+ }
1276
+ ]
1277
+ }
1278
+ """),
1279
+ // all other requests are unauthorized
1280
+ _ => (429, "{}"),
1281
+ };
1282
+ }
1283
+ // override various nuget locations
1284
+ using var tempDir = new TemporaryDirectory();
1285
+ using var _ = new TemporaryEnvironment(
1286
+ [
1287
+ ("NUGET_PACKAGES", Path.Combine(tempDir.DirectoryPath, "NUGET_PACKAGES")),
1288
+ ("NUGET_HTTP_CACHE_PATH", Path.Combine(tempDir.DirectoryPath, "NUGET_HTTP_CACHE_PATH")),
1289
+ ("NUGET_SCRATCH", Path.Combine(tempDir.DirectoryPath, "NUGET_SCRATCH")),
1290
+ ("NUGET_PLUGINS_CACHE_PATH", Path.Combine(tempDir.DirectoryPath, "NUGET_PLUGINS_CACHE_PATH")),
1291
+ ]);
1292
+ using var http = TestHttpServer.CreateTestStringServer(TestHttpHandler);
1293
+ var experimentsManager = new ExperimentsManager() { UseDirectDiscovery = true };
1294
+ await TestDiscoveryAsync(
1295
+ experimentsManager: experimentsManager,
1296
+ workspacePath: "",
1297
+ files:
1298
+ [
1299
+ ("project.csproj", """
1300
+ <Project Sdk="Microsoft.NET.Sdk">
1301
+ <PropertyGroup>
1302
+ <TargetFramework>net8.0</TargetFramework>
1303
+ </PropertyGroup>
1304
+ <ItemGroup>
1305
+ <PackageReference Include="Some.Package" Version="1.2.3" />
1306
+ </ItemGroup>
1307
+ </Project>
1308
+ """),
1309
+ ("NuGet.Config", $"""
1310
+ <configuration>
1311
+ <packageSources>
1312
+ <clear />
1313
+ <add key="private_feed" value="{http.BaseUrl.TrimEnd('/')}/index.json" allowInsecureConnections="true" />
1314
+ </packageSources>
1315
+ </configuration>
1316
+ """),
1317
+ ],
1318
+ expectedResult: new()
1319
+ {
1320
+ Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"]),
1321
+ Path = "",
1322
+ Projects = [],
1323
+ }
1324
+ );
1325
+ }
1326
+
1250
1327
  [LinuxOnlyFact]
1251
1328
  public async Task DiscoverySucceedsWhenNoWindowsAppRefPackageCanBeFound()
1252
1329
  {
@@ -106,7 +106,10 @@ public class RunWorkerTests
106
106
  </ItemGroup>
107
107
  </Project>
108
108
  """.SetEOL(EOL));
109
- return new UpdateOperationResult();
109
+ return new UpdateOperationResult()
110
+ {
111
+ UpdateOperations = [],
112
+ };
110
113
  }),
111
114
  expectedResult: new RunResult()
112
115
  {
@@ -314,7 +317,10 @@ public class RunWorkerTests
314
317
  </ItemGroup>
315
318
  </Project>
316
319
  """.SetEOL(EOL));
317
- return new UpdateOperationResult();
320
+ return new UpdateOperationResult()
321
+ {
322
+ UpdateOperations = [],
323
+ };
318
324
  }),
319
325
  expectedResult: new RunResult()
320
326
  {
@@ -681,7 +687,10 @@ public class RunWorkerTests
681
687
  throw new NotSupportedException();
682
688
  }
683
689
 
684
- return new UpdateOperationResult();
690
+ return new UpdateOperationResult()
691
+ {
692
+ UpdateOperations = [],
693
+ };
685
694
  }),
686
695
  expectedResult: new RunResult()
687
696
  {
@@ -1091,7 +1100,10 @@ public class RunWorkerTests
1091
1100
  throw new NotSupportedException();
1092
1101
  }
1093
1102
 
1094
- return new UpdateOperationResult();
1103
+ return new UpdateOperationResult()
1104
+ {
1105
+ UpdateOperations = [],
1106
+ };
1095
1107
  }),
1096
1108
  expectedResult: new RunResult()
1097
1109
  {
@@ -1553,7 +1565,10 @@ public class RunWorkerTests
1553
1565
  </PropertyGroup>
1554
1566
  </Project>
1555
1567
  """.SetEOL(EOL));
1556
- return new UpdateOperationResult();
1568
+ return new UpdateOperationResult()
1569
+ {
1570
+ UpdateOperations = [],
1571
+ };
1557
1572
  }),
1558
1573
  expectedResult: new RunResult()
1559
1574
  {
@@ -2316,7 +2331,10 @@ public class RunWorkerTests
2316
2331
  _ => throw new NotImplementedException("unreachable")
2317
2332
  };
2318
2333
  await File.WriteAllTextAsync(dependencyFilePath, updatedContent);
2319
- return new UpdateOperationResult();
2334
+ return new UpdateOperationResult()
2335
+ {
2336
+ UpdateOperations = [],
2337
+ };
2320
2338
  }),
2321
2339
  expectedResult: new()
2322
2340
  {
@@ -649,6 +649,14 @@ public class SerializationTests
649
649
  """
650
650
  ];
651
651
 
652
+ yield return
653
+ [
654
+ new PrivateSourceBadResponse(["url1", "url2"]),
655
+ """
656
+ {"data":{"error-type":"private_source_bad_response","error-details":{"source":"(url1|url2)"}}}
657
+ """
658
+ ];
659
+
652
660
  yield return
653
661
  [
654
662
  new PullRequestExistsForLatestVersion("dep", "ver"),
@@ -0,0 +1,177 @@
1
+ using System.Collections.Immutable;
2
+
3
+ using NuGet.Versioning;
4
+
5
+ using NuGetUpdater.Core.Test.Utilities;
6
+ using NuGetUpdater.Core.Updater;
7
+
8
+ using Xunit;
9
+
10
+ namespace NuGetUpdater.Core.Test.Update;
11
+
12
+ public class PackageReferenceUpdaterTests
13
+ {
14
+ [Theory]
15
+ [MemberData(nameof(ComputeUpdateOperationsTestData))]
16
+ public async Task ComputeUpdateOperations
17
+ (
18
+ ImmutableArray<Dependency> topLevelDependencies,
19
+ ImmutableArray<Dependency> requestedUpdates,
20
+ ImmutableArray<Dependency> resolvedDependencies,
21
+ ImmutableArray<UpdateOperationBase> expectedUpdateOperations
22
+ )
23
+ {
24
+ // arrange
25
+ using var repoRoot = await TemporaryDirectory.CreateWithContentsAsync(("project.csproj", "<Project Sdk=\"Microsoft.NET.Sdk\" />"));
26
+ var projectPath = Path.Combine(repoRoot.DirectoryPath, "project.csproj");
27
+ var experimentsManager = new ExperimentsManager() { UseDirectDiscovery = true };
28
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
29
+ MockNuGetPackage.CreateSimplePackage("Parent.Package", "1.0.0", "net9.0", [(null, [("Transitive.Package", "1.0.0")])]),
30
+ MockNuGetPackage.CreateSimplePackage("Parent.Package", "2.0.0", "net9.0", [(null, [("Transitive.Package", "2.0.0")])]),
31
+ MockNuGetPackage.CreateSimplePackage("Transitive.Package", "1.0.0", "net9.0", [(null, [("Super.Transitive.Package", "1.0.0")])]),
32
+ MockNuGetPackage.CreateSimplePackage("Transitive.Package", "2.0.0", "net9.0", [(null, [("Super.Transitive.Package", "2.0.0")])]),
33
+ MockNuGetPackage.CreateSimplePackage("Super.Transitive.Package", "1.0.0", "net9.0"),
34
+ MockNuGetPackage.CreateSimplePackage("Super.Transitive.Package", "2.0.0", "net9.0")
35
+ ], repoRoot.DirectoryPath);
36
+
37
+ // act
38
+ var actualUpdateOperations = await PackageReferenceUpdater.ComputeUpdateOperations(
39
+ repoRoot.DirectoryPath,
40
+ projectPath,
41
+ "net9.0",
42
+ topLevelDependencies,
43
+ requestedUpdates,
44
+ resolvedDependencies,
45
+ experimentsManager,
46
+ new TestLogger());
47
+
48
+ // assert
49
+ AssertEx.Equal(expectedUpdateOperations, actualUpdateOperations);
50
+ }
51
+
52
+ public static IEnumerable<object[]> ComputeUpdateOperationsTestData()
53
+ {
54
+ // single dependency update
55
+ yield return
56
+ [
57
+ // topLevelDependencies
58
+ ImmutableArray.Create(
59
+ new Dependency("Some.Package", "1.0.0", DependencyType.PackageReference),
60
+ new Dependency("Unrelated.Package", "2.0.0", DependencyType.PackageReference)
61
+ ),
62
+
63
+ // requestedUpdates
64
+ ImmutableArray.Create(
65
+ new Dependency("Some.Package", "1.0.1", DependencyType.PackageReference)
66
+ ),
67
+
68
+ // resolvedDependencies
69
+ ImmutableArray.Create(
70
+ new Dependency("Some.Package", "1.0.1", DependencyType.PackageReference),
71
+ new Dependency("Unrelated.Package", "2.0.0", DependencyType.PackageReference)
72
+ ),
73
+
74
+ // expectedUpdateOperations
75
+ ImmutableArray.Create<UpdateOperationBase>(
76
+ new DirectUpdate()
77
+ {
78
+ DependencyName = "Some.Package",
79
+ NewVersion = NuGetVersion.Parse("1.0.1"),
80
+ UpdatedFiles = [],
81
+ }
82
+ )
83
+ ];
84
+
85
+ // dependency was updated by pinning
86
+ yield return
87
+ [
88
+ // topLevelDependencies
89
+ ImmutableArray.Create(
90
+ new Dependency("Top.Level.Package", "1.0.0", DependencyType.PackageReference)
91
+ ),
92
+
93
+ // requestedUpdates
94
+ ImmutableArray.Create(
95
+ new Dependency("Transitive.Package", "2.0.0", DependencyType.PackageReference)
96
+ ),
97
+
98
+ // resolvedDependencies
99
+ ImmutableArray.Create(
100
+ new Dependency("Top.Level.Package", "1.0.0", DependencyType.PackageReference),
101
+ new Dependency("Transitive.Package", "2.0.0", DependencyType.PackageReference)
102
+ ),
103
+
104
+ // expectedUpdateOperations
105
+ ImmutableArray.Create<UpdateOperationBase>(
106
+ new PinnedUpdate()
107
+ {
108
+ DependencyName = "Transitive.Package",
109
+ NewVersion = NuGetVersion.Parse("2.0.0"),
110
+ UpdatedFiles = [],
111
+ }
112
+ )
113
+ ];
114
+
115
+ // dependency was updated by updating parent 1 level up
116
+ yield return
117
+ [
118
+ // topLevelDependencies
119
+ ImmutableArray.Create(
120
+ new Dependency("Parent.Package", "1.0.0", DependencyType.PackageReference)
121
+ ),
122
+
123
+ // requestedUpdates
124
+ ImmutableArray.Create(
125
+ new Dependency("Transitive.Package", "2.0.0", DependencyType.PackageReference)
126
+ ),
127
+
128
+ // resolvedDependencies
129
+ ImmutableArray.Create(
130
+ new Dependency("Parent.Package", "2.0.0", DependencyType.PackageReference)
131
+ ),
132
+
133
+ // expectedUpdateOperations
134
+ ImmutableArray.Create<UpdateOperationBase>(
135
+ new ParentUpdate()
136
+ {
137
+ DependencyName = "Transitive.Package",
138
+ NewVersion = NuGetVersion.Parse("2.0.0"),
139
+ UpdatedFiles = [],
140
+ ParentDependencyName = "Parent.Package",
141
+ ParentNewVersion = NuGetVersion.Parse("2.0.0"),
142
+ }
143
+ )
144
+ ];
145
+
146
+ // dependency was updated by updating parent 2 levels up
147
+ yield return
148
+ [
149
+ // topLevelDependencies
150
+ ImmutableArray.Create(
151
+ new Dependency("Parent.Package", "1.0.0", DependencyType.PackageReference)
152
+ ),
153
+
154
+ // requestedUpdates
155
+ ImmutableArray.Create(
156
+ new Dependency("Super.Transitive.Package", "2.0.0", DependencyType.PackageReference)
157
+ ),
158
+
159
+ // resolvedDependencies
160
+ ImmutableArray.Create(
161
+ new Dependency("Parent.Package", "2.0.0", DependencyType.PackageReference)
162
+ ),
163
+
164
+ // expectedUpdateOperations
165
+ ImmutableArray.Create<UpdateOperationBase>(
166
+ new ParentUpdate()
167
+ {
168
+ DependencyName = "Super.Transitive.Package",
169
+ NewVersion = NuGetVersion.Parse("2.0.0"),
170
+ UpdatedFiles = [],
171
+ ParentDependencyName = "Parent.Package",
172
+ ParentNewVersion = NuGetVersion.Parse("2.0.0"),
173
+ }
174
+ )
175
+ ];
176
+ }
177
+ }
@@ -0,0 +1,130 @@
1
+ using NuGet.Versioning;
2
+
3
+ using NuGetUpdater.Core.Test.Utilities;
4
+ using NuGetUpdater.Core.Updater;
5
+
6
+ using Xunit;
7
+
8
+ namespace NuGetUpdater.Core.Test.Update;
9
+
10
+ public class UpdateOperationBaseTests
11
+ {
12
+ [Fact]
13
+ public void GetReport()
14
+ {
15
+ // arrange
16
+ var updateOperations = new UpdateOperationBase[]
17
+ {
18
+ new DirectUpdate()
19
+ {
20
+ DependencyName = "Package.A",
21
+ NewVersion = NuGetVersion.Parse("1.0.0"),
22
+ UpdatedFiles = ["file/a.txt"]
23
+ },
24
+ new PinnedUpdate()
25
+ {
26
+ DependencyName = "Package.B",
27
+ NewVersion = NuGetVersion.Parse("2.0.0"),
28
+ UpdatedFiles = ["file/b.txt"]
29
+ },
30
+ new ParentUpdate()
31
+ {
32
+ DependencyName = "Package.C",
33
+ NewVersion = NuGetVersion.Parse("3.0.0"),
34
+ UpdatedFiles = ["file/c.txt"],
35
+ ParentDependencyName = "Package.D",
36
+ ParentNewVersion = NuGetVersion.Parse("4.0.0"),
37
+ },
38
+ };
39
+
40
+ // act
41
+ var actualReport = UpdateOperationBase.GenerateUpdateOperationReport(updateOperations);
42
+
43
+ // assert
44
+ var expectedReport = """
45
+ Performed the following updates:
46
+ - Updated Package.A to 1.0.0 in file/a.txt
47
+ - Pinned Package.B at 2.0.0 in file/b.txt
48
+ - Updated Package.C to 3.0.0 indirectly via Package.D/4.0.0 in file/c.txt
49
+ """.Replace("\r", "");
50
+ Assert.Equal(expectedReport, actualReport);
51
+ }
52
+
53
+ [Fact]
54
+ public void NormalizeUpdateOperationCollection_SortAndDistinct()
55
+ {
56
+ // arrange
57
+ var repoRootPath = "/repo/root";
58
+ var updateOperations = new UpdateOperationBase[]
59
+ {
60
+ new DirectUpdate()
61
+ {
62
+ DependencyName = "Dependency.Direct",
63
+ NewVersion = NuGetVersion.Parse("1.0.0"),
64
+ UpdatedFiles = ["/repo/root/file/a.txt"]
65
+ },
66
+ new PinnedUpdate()
67
+ {
68
+ DependencyName = "Dependency.Pinned",
69
+ NewVersion = NuGetVersion.Parse("2.0.0"),
70
+ UpdatedFiles = ["/repo/root/file/b.txt"]
71
+ },
72
+ // this is the same as the first item and will be removed
73
+ new DirectUpdate()
74
+ {
75
+ DependencyName = "Dependency.Direct",
76
+ NewVersion = NuGetVersion.Parse("1.0.0"),
77
+ UpdatedFiles = ["/repo/root/file/a.txt"]
78
+ },
79
+ new ParentUpdate()
80
+ {
81
+ DependencyName = "Dependency.Parent",
82
+ NewVersion = NuGetVersion.Parse("3.0.0"),
83
+ UpdatedFiles = ["/repo/root/file/c.txt"],
84
+ ParentDependencyName = "Dependency.Root",
85
+ ParentNewVersion = NuGetVersion.Parse("4.0.0"),
86
+ },
87
+ };
88
+
89
+ // act
90
+ var normalizedOperations = UpdateOperationBase.NormalizeUpdateOperationCollection(repoRootPath, updateOperations);
91
+ var normalizedDependencyNames = string.Join(", ", normalizedOperations.Select(o => o.DependencyName));
92
+
93
+ // assert
94
+ var expectedDependencyNames = "Dependency.Direct, Dependency.Parent, Dependency.Pinned";
95
+ Assert.Equal(expectedDependencyNames, normalizedDependencyNames);
96
+ }
97
+
98
+ [Fact]
99
+ public void NormalizeUpdateOperationCollection_CombinedOnTypeAndDependency()
100
+ {
101
+ // arrange
102
+ var repoRootPath = "/repo/root";
103
+ var updateOperations = new UpdateOperationBase[]
104
+ {
105
+ // both operations are the same type, same dependency, same version => files are combined
106
+ new DirectUpdate()
107
+ {
108
+ DependencyName = "Dependency.Direct",
109
+ NewVersion = NuGetVersion.Parse("1.0.0"),
110
+ UpdatedFiles = ["/repo/root/file/b.txt"]
111
+ },
112
+ new DirectUpdate()
113
+ {
114
+ DependencyName = "Dependency.Direct",
115
+ NewVersion = NuGetVersion.Parse("1.0.0"),
116
+ UpdatedFiles = ["/repo/root/file/a.txt"]
117
+ },
118
+ };
119
+
120
+ // act
121
+ var normalizedOperations = UpdateOperationBase.NormalizeUpdateOperationCollection(repoRootPath, updateOperations);
122
+
123
+ // assert
124
+ var singleUpdate = Assert.Single(normalizedOperations);
125
+ var directUpdate = Assert.IsType<DirectUpdate>(singleUpdate);
126
+ Assert.Equal("Dependency.Direct", directUpdate.DependencyName);
127
+ Assert.Equal(NuGetVersion.Parse("1.0.0"), directUpdate.NewVersion);
128
+ AssertEx.Equal(["/file/a.txt", "/file/b.txt"], directUpdate.UpdatedFiles);
129
+ }
130
+ }
@@ -3,6 +3,7 @@ using System.Text.Json;
3
3
  using NuGetUpdater.Core.Run;
4
4
  using NuGetUpdater.Core.Run.ApiModel;
5
5
  using NuGetUpdater.Core.Test.Updater;
6
+ using NuGetUpdater.Core.Test.Utilities;
6
7
  using NuGetUpdater.Core.Updater;
7
8
 
8
9
  using Xunit;
@@ -191,6 +192,10 @@ public abstract class UpdateWorkerTestBase : TestBase
191
192
  else
192
193
  {
193
194
  Assert.Null(actualResult.Error);
195
+ if (expectedResult is not null)
196
+ {
197
+ AssertEx.Equal(expectedResult.UpdateOperations, actualResult.UpdateOperations, UpdateOperationBaseComparer.Instance);
198
+ }
194
199
  }
195
200
  }
196
201
 
@@ -1,5 +1,7 @@
1
1
  using System.Text.Json;
2
2
 
3
+ using NuGet.Versioning;
4
+
3
5
  using NuGetUpdater.Core.Run.ApiModel;
4
6
  using NuGetUpdater.Core.Updater;
5
7
 
@@ -12,16 +14,14 @@ public partial class UpdateWorkerTests
12
14
  public class Mixed : UpdateWorkerTestBase
13
15
  {
14
16
  [Fact]
15
- public async Task ResultFileHasCorrectShapeForAuthenticationFailure()
17
+ public void ResultFileHasCorrectShapeForAuthenticationFailure()
16
18
  {
17
- using var temporaryDirectory = await TemporaryDirectory.CreateWithContentsAsync([]);
18
19
  var result = new UpdateOperationResult()
19
20
  {
20
21
  Error = new PrivateSourceAuthenticationFailure(["<some package feed>"]),
22
+ UpdateOperations = [],
21
23
  };
22
- var resultFilePath = Path.Combine(temporaryDirectory.DirectoryPath, "update-result.json");
23
- await UpdaterWorker.WriteResultFile(result, resultFilePath, new TestLogger());
24
- var resultContent = await File.ReadAllTextAsync(resultFilePath);
24
+ var resultContent = UpdaterWorker.Serialize(result);
25
25
 
26
26
  // raw result file should look like this:
27
27
  // {
@@ -44,6 +44,72 @@ public partial class UpdateWorkerTests
44
44
  Assert.Equal("(<some package feed>)", source.GetString());
45
45
  }
46
46
 
47
+ [Fact]
48
+ public void ResultFileListsUpdateOperations()
49
+ {
50
+ var result = new UpdateOperationResult()
51
+ {
52
+ Error = null,
53
+ UpdateOperations = [
54
+ new DirectUpdate()
55
+ {
56
+ DependencyName = "Package.A",
57
+ NewVersion = NuGetVersion.Parse("1.0.0"),
58
+ UpdatedFiles = ["a.txt"]
59
+ },
60
+ new PinnedUpdate()
61
+ {
62
+ DependencyName = "Package.B",
63
+ NewVersion = NuGetVersion.Parse("2.0.0"),
64
+ UpdatedFiles = ["b.txt"]
65
+ },
66
+ new ParentUpdate()
67
+ {
68
+ DependencyName = "Package.C",
69
+ NewVersion = NuGetVersion.Parse("3.0.0"),
70
+ UpdatedFiles = ["c.txt"],
71
+ ParentDependencyName = "Package.D",
72
+ ParentNewVersion = NuGetVersion.Parse("4.0.0"),
73
+ }
74
+ ]
75
+ };
76
+ var actualJson = UpdaterWorker.Serialize(result).Replace("\r", "");
77
+ var expectedJson = """
78
+ {
79
+ "UpdateOperations": [
80
+ {
81
+ "Type": "DirectUpdate",
82
+ "DependencyName": "Package.A",
83
+ "NewVersion": "1.0.0",
84
+ "UpdatedFiles": [
85
+ "a.txt"
86
+ ]
87
+ },
88
+ {
89
+ "Type": "PinnedUpdate",
90
+ "DependencyName": "Package.B",
91
+ "NewVersion": "2.0.0",
92
+ "UpdatedFiles": [
93
+ "b.txt"
94
+ ]
95
+ },
96
+ {
97
+ "Type": "ParentUpdate",
98
+ "ParentDependencyName": "Package.D",
99
+ "ParentNewVersion": "4.0.0",
100
+ "DependencyName": "Package.C",
101
+ "NewVersion": "3.0.0",
102
+ "UpdatedFiles": [
103
+ "c.txt"
104
+ ]
105
+ }
106
+ ],
107
+ "Error": null
108
+ }
109
+ """.Replace("\r", "");
110
+ Assert.Equal(expectedJson, actualJson);
111
+ }
112
+
47
113
  [Fact]
48
114
  public async Task ForPackagesProject_UpdatePackageReference_InBuildProps()
49
115
  {