dependabot-nuget 0.315.0 → 0.316.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/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +1 -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/Run/ApiModel/ClosePullRequest.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CreatePullRequest.cs +47 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +60 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +151 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +4 -18
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequestExistsForSecurityUpdate.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/SecurityUpdateDependencyNotFound.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/SecurityUpdateIgnored.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/SecurityUpdateNotFound.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/SecurityUpdateNotPossible.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdatePullRequest.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ModifiedFilesTracker.cs +151 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +78 -32
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +99 -111
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +169 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +271 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/IUpdateHandler.cs +22 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +192 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +187 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +175 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +43 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +17 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +15 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MarkdownListBuilder.cs +65 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/ApiModel/JobTests.cs +405 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +92 -82
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +5 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +67 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +445 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestMessageTests.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +260 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +30 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +69 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandlerTests.cs +766 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +636 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandlerTests.cs +513 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandlerTests.cs +806 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandlerTests.cs +589 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/UpdateHandlerSelectionTests.cs +183 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/UpdateHandlersTestsBase.cs +43 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationBaseTests.cs +121 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +51 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MarkdownListBuilderTests.cs +42 -0
- metadata +26 -4
@@ -0,0 +1,183 @@
|
|
1
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
2
|
+
using NuGetUpdater.Core.Run.UpdateHandlers;
|
3
|
+
using NuGetUpdater.Core.Run;
|
4
|
+
using Xunit;
|
5
|
+
|
6
|
+
namespace NuGetUpdater.Core.Test.Run.UpdateHandlers;
|
7
|
+
|
8
|
+
public class UpdateHandlerSelectionTests : UpdateHandlersTestsBase
|
9
|
+
{
|
10
|
+
[Theory]
|
11
|
+
[MemberData(nameof(GetUpdateHandlerFromJobTestData))]
|
12
|
+
public void GetUpdateHandlerFromJob(Job job, IUpdateHandler expectedUpdateHandler)
|
13
|
+
{
|
14
|
+
var actualUpdateHandler = RunWorker.GetUpdateHandler(job);
|
15
|
+
Assert.Equal(expectedUpdateHandler.GetType(), actualUpdateHandler.GetType());
|
16
|
+
}
|
17
|
+
|
18
|
+
public static IEnumerable<object[]> GetUpdateHandlerFromJobTestData()
|
19
|
+
{
|
20
|
+
// to ensure we're not depending on any default values, _ALWAYS_ set the following properties explicitly:
|
21
|
+
// Source
|
22
|
+
// Dependencies
|
23
|
+
// DependencyGroups
|
24
|
+
// DependencyGroupToRefresh
|
25
|
+
// SecurityUpdatesOnly
|
26
|
+
// UpdatingAPullRequest
|
27
|
+
|
28
|
+
//
|
29
|
+
// group_update_all_versions
|
30
|
+
//
|
31
|
+
yield return
|
32
|
+
[
|
33
|
+
new Job()
|
34
|
+
{
|
35
|
+
Source = CreateJobSource("/"),
|
36
|
+
Dependencies = [],
|
37
|
+
DependencyGroups = [],
|
38
|
+
DependencyGroupToRefresh = null,
|
39
|
+
SecurityUpdatesOnly = false,
|
40
|
+
UpdatingAPullRequest = false,
|
41
|
+
},
|
42
|
+
GroupUpdateAllVersionsHandler.Instance,
|
43
|
+
];
|
44
|
+
|
45
|
+
yield return
|
46
|
+
[
|
47
|
+
new Job()
|
48
|
+
{
|
49
|
+
Source = CreateJobSource("/"),
|
50
|
+
Dependencies = ["Dependency.A", "Dependency.B"],
|
51
|
+
DependencyGroups = [],
|
52
|
+
DependencyGroupToRefresh = null,
|
53
|
+
SecurityUpdatesOnly = true,
|
54
|
+
UpdatingAPullRequest = false,
|
55
|
+
},
|
56
|
+
GroupUpdateAllVersionsHandler.Instance,
|
57
|
+
];
|
58
|
+
|
59
|
+
yield return
|
60
|
+
[
|
61
|
+
new Job()
|
62
|
+
{
|
63
|
+
Source = CreateJobSource("/"),
|
64
|
+
Dependencies = [],
|
65
|
+
DependencyGroups = [new() { Name = "some-group", AppliesTo = "security-updates" }],
|
66
|
+
DependencyGroupToRefresh = null,
|
67
|
+
SecurityUpdatesOnly = true,
|
68
|
+
UpdatingAPullRequest = false,
|
69
|
+
},
|
70
|
+
GroupUpdateAllVersionsHandler.Instance,
|
71
|
+
];
|
72
|
+
|
73
|
+
//
|
74
|
+
// update_version_group_pr
|
75
|
+
//
|
76
|
+
yield return
|
77
|
+
[
|
78
|
+
new Job()
|
79
|
+
{
|
80
|
+
Source = CreateJobSource("/dir1", "/dir2"),
|
81
|
+
Dependencies = ["Some.Dependency"],
|
82
|
+
DependencyGroups = [new() { Name = "some-group", AppliesTo = "security-updates" }], // this
|
83
|
+
DependencyGroupToRefresh = "some-group",
|
84
|
+
SecurityUpdatesOnly = false,
|
85
|
+
UpdatingAPullRequest = true,
|
86
|
+
},
|
87
|
+
RefreshGroupUpdatePullRequestHandler.Instance,
|
88
|
+
];
|
89
|
+
|
90
|
+
yield return
|
91
|
+
[
|
92
|
+
new Job()
|
93
|
+
{
|
94
|
+
Source = CreateJobSource("/src"),
|
95
|
+
Dependencies = ["Dependency.A", "Dependency.B"],
|
96
|
+
DependencyGroups = [new() { Name = "some-group", AppliesTo = "security-updates" }], // this
|
97
|
+
DependencyGroupToRefresh = "some-group",
|
98
|
+
SecurityUpdatesOnly = true,
|
99
|
+
UpdatingAPullRequest = true,
|
100
|
+
},
|
101
|
+
RefreshGroupUpdatePullRequestHandler.Instance,
|
102
|
+
];
|
103
|
+
|
104
|
+
yield return
|
105
|
+
[
|
106
|
+
new Job()
|
107
|
+
{
|
108
|
+
Source = CreateJobSource("/src"),
|
109
|
+
Dependencies = ["Some.Dependency"],
|
110
|
+
DependencyGroups = [new() { Name = "some-group", AppliesTo = "security-updates" }],
|
111
|
+
DependencyGroupToRefresh = "some-group",
|
112
|
+
SecurityUpdatesOnly = true,
|
113
|
+
UpdatingAPullRequest = true,
|
114
|
+
},
|
115
|
+
RefreshGroupUpdatePullRequestHandler.Instance,
|
116
|
+
];
|
117
|
+
|
118
|
+
yield return
|
119
|
+
[
|
120
|
+
new Job()
|
121
|
+
{
|
122
|
+
Source = CreateJobSource("/src"),
|
123
|
+
Dependencies = ["Some.Dependency"],
|
124
|
+
DependencyGroups = [new() { Name = "some-group", AppliesTo = "security-updates" }],
|
125
|
+
DependencyGroupToRefresh = "some-group",
|
126
|
+
SecurityUpdatesOnly = true,
|
127
|
+
UpdatingAPullRequest = true,
|
128
|
+
},
|
129
|
+
RefreshGroupUpdatePullRequestHandler.Instance,
|
130
|
+
];
|
131
|
+
|
132
|
+
//
|
133
|
+
// create_security_pr
|
134
|
+
//
|
135
|
+
yield return
|
136
|
+
[
|
137
|
+
new Job()
|
138
|
+
{
|
139
|
+
Source = CreateJobSource("/src"),
|
140
|
+
Dependencies = ["Some.Dependency"],
|
141
|
+
DependencyGroups = [],
|
142
|
+
DependencyGroupToRefresh = null,
|
143
|
+
SecurityUpdatesOnly = true,
|
144
|
+
UpdatingAPullRequest = false,
|
145
|
+
},
|
146
|
+
CreateSecurityUpdatePullRequestHandler.Instance,
|
147
|
+
];
|
148
|
+
|
149
|
+
//
|
150
|
+
// update_security_pr
|
151
|
+
//
|
152
|
+
yield return
|
153
|
+
[
|
154
|
+
new Job()
|
155
|
+
{
|
156
|
+
Source = CreateJobSource("/src"),
|
157
|
+
Dependencies = ["Some.Dependency"],
|
158
|
+
DependencyGroups = [],
|
159
|
+
DependencyGroupToRefresh = null,
|
160
|
+
SecurityUpdatesOnly = true,
|
161
|
+
UpdatingAPullRequest = true,
|
162
|
+
},
|
163
|
+
RefreshSecurityUpdatePullRequestHandler.Instance,
|
164
|
+
];
|
165
|
+
|
166
|
+
//
|
167
|
+
// update_version_pr
|
168
|
+
//
|
169
|
+
yield return
|
170
|
+
[
|
171
|
+
new Job()
|
172
|
+
{
|
173
|
+
Source = CreateJobSource("/src"),
|
174
|
+
Dependencies = ["Some.Dependency"], // must not be empty
|
175
|
+
DependencyGroups = [],
|
176
|
+
DependencyGroupToRefresh = null,
|
177
|
+
SecurityUpdatesOnly = false, // must be false
|
178
|
+
UpdatingAPullRequest = true, // must be true
|
179
|
+
},
|
180
|
+
RefreshVersionUpdatePullRequestHandler.Instance,
|
181
|
+
];
|
182
|
+
}
|
183
|
+
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/UpdateHandlersTestsBase.cs
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
2
|
+
using NuGetUpdater.Core.Run.UpdateHandlers;
|
3
|
+
using NuGetUpdater.Core.Run;
|
4
|
+
using Xunit;
|
5
|
+
|
6
|
+
namespace NuGetUpdater.Core.Test.Run.UpdateHandlers;
|
7
|
+
|
8
|
+
public class UpdateHandlersTestsBase : TestBase
|
9
|
+
{
|
10
|
+
protected static JobSource CreateJobSource(string directory, params string[] additionalDirectories) => new JobSource()
|
11
|
+
{
|
12
|
+
Provider = "github",
|
13
|
+
Repo = "test/repo",
|
14
|
+
Directories = [directory, .. additionalDirectories],
|
15
|
+
};
|
16
|
+
|
17
|
+
protected Task TestAsync(
|
18
|
+
Job job,
|
19
|
+
IUpdateHandler expectedUpdateHandler,
|
20
|
+
object[] expectedApiMessages,
|
21
|
+
(string Name, string Contents)[] files,
|
22
|
+
MockNuGetPackage[]? packages = null,
|
23
|
+
IDiscoveryWorker? discoveryWorker = null,
|
24
|
+
IAnalyzeWorker? analyzeWorker = null,
|
25
|
+
IUpdaterWorker? updaterWorker = null,
|
26
|
+
ExperimentsManager? experimentsManager = null
|
27
|
+
)
|
28
|
+
{
|
29
|
+
// first ensure we're using the correct updater
|
30
|
+
var actualUpdateHandler = RunWorker.GetUpdateHandler(job);
|
31
|
+
Assert.Equal(actualUpdateHandler.GetType(), expectedUpdateHandler.GetType());
|
32
|
+
|
33
|
+
// the new runner doesn't report this result object so we can expect an empty one
|
34
|
+
var expectedResult = new RunResult()
|
35
|
+
{
|
36
|
+
Base64DependencyFiles = [],
|
37
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
38
|
+
};
|
39
|
+
experimentsManager ??= new ExperimentsManager();
|
40
|
+
experimentsManager = experimentsManager with { UseLegacyUpdateHandler = false };
|
41
|
+
return RunWorkerTests.RunAsync(job, files, discoveryWorker, analyzeWorker, updaterWorker, expectedResult, expectedApiMessages, packages, experimentsManager);
|
42
|
+
}
|
43
|
+
}
|
@@ -89,7 +89,7 @@ public class UpdatedDependencyListTests
|
|
89
89
|
]
|
90
90
|
}
|
91
91
|
};
|
92
|
-
var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery
|
92
|
+
var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery);
|
93
93
|
var expectedDependencyList = new UpdatedDependencyList()
|
94
94
|
{
|
95
95
|
Dependencies =
|
@@ -213,7 +213,7 @@ public class UpdatedDependencyListTests
|
|
213
213
|
};
|
214
214
|
|
215
215
|
// act
|
216
|
-
var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery
|
216
|
+
var updatedDependencyList = RunWorker.GetUpdatedDependencyListFromDiscovery(discovery);
|
217
217
|
var expectedDependencyList = new UpdatedDependencyList()
|
218
218
|
{
|
219
219
|
Dependencies = [],
|
@@ -1,5 +1,9 @@
|
|
1
|
+
using System.Text.Json;
|
2
|
+
|
1
3
|
using NuGet.Versioning;
|
2
4
|
|
5
|
+
using NuGetUpdater.Core.Run;
|
6
|
+
using NuGetUpdater.Core.Run.ApiModel;
|
3
7
|
using NuGetUpdater.Core.Test.Utilities;
|
4
8
|
using NuGetUpdater.Core.Updater;
|
5
9
|
|
@@ -21,19 +25,28 @@ public class UpdateOperationBaseTests
|
|
21
25
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
22
26
|
UpdatedFiles = ["file/a.txt"]
|
23
27
|
},
|
24
|
-
new
|
28
|
+
new DirectUpdate()
|
25
29
|
{
|
26
30
|
DependencyName = "Package.B",
|
31
|
+
OldVersion = NuGetVersion.Parse("0.2.0"),
|
27
32
|
NewVersion = NuGetVersion.Parse("2.0.0"),
|
28
33
|
UpdatedFiles = ["file/b.txt"]
|
29
34
|
},
|
30
|
-
new
|
35
|
+
new PinnedUpdate()
|
31
36
|
{
|
32
37
|
DependencyName = "Package.C",
|
38
|
+
OldVersion = NuGetVersion.Parse("0.3.0"),
|
33
39
|
NewVersion = NuGetVersion.Parse("3.0.0"),
|
34
|
-
UpdatedFiles = ["file/c.txt"]
|
35
|
-
|
36
|
-
|
40
|
+
UpdatedFiles = ["file/c.txt"]
|
41
|
+
},
|
42
|
+
new ParentUpdate()
|
43
|
+
{
|
44
|
+
DependencyName = "Package.D",
|
45
|
+
OldVersion = NuGetVersion.Parse("0.4.0"),
|
46
|
+
NewVersion = NuGetVersion.Parse("4.0.0"),
|
47
|
+
UpdatedFiles = ["file/d.txt"],
|
48
|
+
ParentDependencyName = "Package.E",
|
49
|
+
ParentNewVersion = NuGetVersion.Parse("5.0.0"),
|
37
50
|
},
|
38
51
|
};
|
39
52
|
|
@@ -44,8 +57,9 @@ public class UpdateOperationBaseTests
|
|
44
57
|
var expectedReport = """
|
45
58
|
Performed the following updates:
|
46
59
|
- Updated Package.A to 1.0.0 in file/a.txt
|
47
|
-
-
|
48
|
-
-
|
60
|
+
- Updated Package.B from 0.2.0 to 2.0.0 in file/b.txt
|
61
|
+
- Pinned Package.C at 3.0.0 in file/c.txt
|
62
|
+
- Updated Package.D to 4.0.0 indirectly via Package.E/5.0.0 in file/d.txt
|
49
63
|
""".Replace("\r", "");
|
50
64
|
Assert.Equal(expectedReport, actualReport);
|
51
65
|
}
|
@@ -60,12 +74,14 @@ public class UpdateOperationBaseTests
|
|
60
74
|
new DirectUpdate()
|
61
75
|
{
|
62
76
|
DependencyName = "Dependency.Direct",
|
77
|
+
OldVersion = NuGetVersion.Parse("0.1.0"),
|
63
78
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
64
79
|
UpdatedFiles = ["/repo/root/file/a.txt"]
|
65
80
|
},
|
66
81
|
new PinnedUpdate()
|
67
82
|
{
|
68
83
|
DependencyName = "Dependency.Pinned",
|
84
|
+
OldVersion = NuGetVersion.Parse("0.2.0"),
|
69
85
|
NewVersion = NuGetVersion.Parse("2.0.0"),
|
70
86
|
UpdatedFiles = ["/repo/root/file/b.txt"]
|
71
87
|
},
|
@@ -73,12 +89,14 @@ public class UpdateOperationBaseTests
|
|
73
89
|
new DirectUpdate()
|
74
90
|
{
|
75
91
|
DependencyName = "Dependency.Direct",
|
92
|
+
OldVersion = NuGetVersion.Parse("0.1.0"),
|
76
93
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
77
94
|
UpdatedFiles = ["/repo/root/file/a.txt"]
|
78
95
|
},
|
79
96
|
new ParentUpdate()
|
80
97
|
{
|
81
98
|
DependencyName = "Dependency.Parent",
|
99
|
+
OldVersion = NuGetVersion.Parse("0.3.0"),
|
82
100
|
NewVersion = NuGetVersion.Parse("3.0.0"),
|
83
101
|
UpdatedFiles = ["/repo/root/file/c.txt"],
|
84
102
|
ParentDependencyName = "Dependency.Root",
|
@@ -106,12 +124,14 @@ public class UpdateOperationBaseTests
|
|
106
124
|
new DirectUpdate()
|
107
125
|
{
|
108
126
|
DependencyName = "Dependency.Direct",
|
127
|
+
OldVersion = NuGetVersion.Parse("0.1.0"),
|
109
128
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
110
129
|
UpdatedFiles = ["/repo/root/file/b.txt"]
|
111
130
|
},
|
112
131
|
new DirectUpdate()
|
113
132
|
{
|
114
133
|
DependencyName = "Dependency.Direct",
|
134
|
+
OldVersion = NuGetVersion.Parse("0.1.0"),
|
115
135
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
116
136
|
UpdatedFiles = ["/repo/root/file/a.txt"]
|
117
137
|
},
|
@@ -127,4 +147,98 @@ public class UpdateOperationBaseTests
|
|
127
147
|
Assert.Equal(NuGetVersion.Parse("1.0.0"), directUpdate.NewVersion);
|
128
148
|
AssertEx.Equal(["/file/a.txt", "/file/b.txt"], directUpdate.UpdatedFiles);
|
129
149
|
}
|
150
|
+
|
151
|
+
[Theory]
|
152
|
+
[MemberData(nameof(ToReportedDependencyTestData))]
|
153
|
+
public void ToReportedDependency(UpdateOperationBase updateOperation, ReportedDependency[] previouslyReportedDependencies, Dependency[] updatedDependencies, ReportedDependency expectedReportedDependency)
|
154
|
+
{
|
155
|
+
var actualReportedDependency = updateOperation.ToReportedDependency("project.csproj", previouslyReportedDependencies, updatedDependencies);
|
156
|
+
|
157
|
+
var actualReportedJson = JsonSerializer.Serialize(actualReportedDependency, RunWorker.SerializerOptions);
|
158
|
+
var expectedReportedJson = JsonSerializer.Serialize(expectedReportedDependency, RunWorker.SerializerOptions);
|
159
|
+
Assert.Equal(expectedReportedJson, actualReportedJson);
|
160
|
+
}
|
161
|
+
|
162
|
+
public static IEnumerable<object[]> ToReportedDependencyTestData()
|
163
|
+
{
|
164
|
+
// direct mapping
|
165
|
+
yield return
|
166
|
+
[
|
167
|
+
// updateOperation
|
168
|
+
new DirectUpdate()
|
169
|
+
{
|
170
|
+
DependencyName = "Some.Package",
|
171
|
+
NewVersion = NuGetVersion.Parse("2.0.0"),
|
172
|
+
UpdatedFiles = ["project.csproj"]
|
173
|
+
},
|
174
|
+
// previouslyReportedDependencies
|
175
|
+
new ReportedDependency[]
|
176
|
+
{
|
177
|
+
new()
|
178
|
+
{
|
179
|
+
Name = "Some.Package",
|
180
|
+
Version = "1.0.0",
|
181
|
+
Requirements = [
|
182
|
+
new() { Requirement = "1.0.0", File = "project.csproj" }
|
183
|
+
]
|
184
|
+
}
|
185
|
+
},
|
186
|
+
// updatedDependencies
|
187
|
+
new Dependency[]
|
188
|
+
{
|
189
|
+
new("Some.Package", "2.0.0", DependencyType.Unknown, InfoUrl: "https://nuget.example.com/Some.Package"),
|
190
|
+
},
|
191
|
+
// expectedReportedDependency
|
192
|
+
new ReportedDependency()
|
193
|
+
{
|
194
|
+
Name = "Some.Package",
|
195
|
+
Version = "2.0.0",
|
196
|
+
Requirements = [
|
197
|
+
new() { Requirement = "2.0.0", File = "project.csproj", Source = new() { SourceUrl = "https://nuget.example.com/Some.Package" } }
|
198
|
+
],
|
199
|
+
PreviousVersion = "1.0.0",
|
200
|
+
PreviousRequirements = [
|
201
|
+
new() { Requirement = "1.0.0", File = "project.csproj" }
|
202
|
+
],
|
203
|
+
},
|
204
|
+
];
|
205
|
+
|
206
|
+
// updated dependency brought in new package not previously known
|
207
|
+
yield return
|
208
|
+
[
|
209
|
+
// updateOperation
|
210
|
+
new DirectUpdate()
|
211
|
+
{
|
212
|
+
DependencyName = "Transitive.Package",
|
213
|
+
NewVersion = NuGetVersion.Parse("3.0.0"),
|
214
|
+
UpdatedFiles = ["project.csproj"]
|
215
|
+
},
|
216
|
+
// previouslyReportedDependencies
|
217
|
+
new ReportedDependency[]
|
218
|
+
{
|
219
|
+
new()
|
220
|
+
{
|
221
|
+
Name = "Some.Package",
|
222
|
+
Version = "1.0.0",
|
223
|
+
Requirements = [
|
224
|
+
new() { Requirement = "1.0.0", File = "project.csproj" }
|
225
|
+
]
|
226
|
+
}
|
227
|
+
},
|
228
|
+
// updatedDependencies
|
229
|
+
new Dependency[]
|
230
|
+
{
|
231
|
+
new("Transitive.Package", "3.0.0", DependencyType.Unknown),
|
232
|
+
},
|
233
|
+
// expectedReportedDependency
|
234
|
+
new ReportedDependency()
|
235
|
+
{
|
236
|
+
Name = "Transitive.Package",
|
237
|
+
Version = "3.0.0",
|
238
|
+
Requirements = [
|
239
|
+
new() { Requirement = "3.0.0", File = "project.csproj", Source = new() { SourceUrl = null } }
|
240
|
+
],
|
241
|
+
},
|
242
|
+
];
|
243
|
+
}
|
130
244
|
}
|
@@ -54,18 +54,21 @@ public partial class UpdateWorkerTests
|
|
54
54
|
new DirectUpdate()
|
55
55
|
{
|
56
56
|
DependencyName = "Package.A",
|
57
|
+
OldVersion = NuGetVersion.Parse("0.1.0"),
|
57
58
|
NewVersion = NuGetVersion.Parse("1.0.0"),
|
58
59
|
UpdatedFiles = ["a.txt"]
|
59
60
|
},
|
60
61
|
new PinnedUpdate()
|
61
62
|
{
|
62
63
|
DependencyName = "Package.B",
|
64
|
+
OldVersion = NuGetVersion.Parse("0.2.0"),
|
63
65
|
NewVersion = NuGetVersion.Parse("2.0.0"),
|
64
66
|
UpdatedFiles = ["b.txt"]
|
65
67
|
},
|
66
68
|
new ParentUpdate()
|
67
69
|
{
|
68
70
|
DependencyName = "Package.C",
|
71
|
+
OldVersion = NuGetVersion.Parse("0.3.0"),
|
69
72
|
NewVersion = NuGetVersion.Parse("3.0.0"),
|
70
73
|
UpdatedFiles = ["c.txt"],
|
71
74
|
ParentDependencyName = "Package.D",
|
@@ -80,6 +83,7 @@ public partial class UpdateWorkerTests
|
|
80
83
|
{
|
81
84
|
"Type": "DirectUpdate",
|
82
85
|
"DependencyName": "Package.A",
|
86
|
+
"OldVersion": "0.1.0",
|
83
87
|
"NewVersion": "1.0.0",
|
84
88
|
"UpdatedFiles": [
|
85
89
|
"a.txt"
|
@@ -88,6 +92,7 @@ public partial class UpdateWorkerTests
|
|
88
92
|
{
|
89
93
|
"Type": "PinnedUpdate",
|
90
94
|
"DependencyName": "Package.B",
|
95
|
+
"OldVersion": "0.2.0",
|
91
96
|
"NewVersion": "2.0.0",
|
92
97
|
"UpdatedFiles": [
|
93
98
|
"b.txt"
|
@@ -98,6 +103,7 @@ public partial class UpdateWorkerTests
|
|
98
103
|
"ParentDependencyName": "Package.D",
|
99
104
|
"ParentNewVersion": "4.0.0",
|
100
105
|
"DependencyName": "Package.C",
|
106
|
+
"OldVersion": "0.3.0",
|
101
107
|
"NewVersion": "3.0.0",
|
102
108
|
"UpdatedFiles": [
|
103
109
|
"c.txt"
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs
CHANGED
@@ -2576,7 +2576,7 @@ public partial class UpdateWorkerTests
|
|
2576
2576
|
""",
|
2577
2577
|
expectedResult: new()
|
2578
2578
|
{
|
2579
|
-
|
2579
|
+
Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"]),
|
2580
2580
|
UpdateOperations = [],
|
2581
2581
|
}
|
2582
2582
|
);
|
@@ -2654,7 +2654,7 @@ public partial class UpdateWorkerTests
|
|
2654
2654
|
""",
|
2655
2655
|
expectedResult: new()
|
2656
2656
|
{
|
2657
|
-
Error = new DependencyNotFound("Unrelated.Package
|
2657
|
+
Error = new DependencyNotFound("Unrelated.Package"),
|
2658
2658
|
UpdateOperations = [],
|
2659
2659
|
}
|
2660
2660
|
);
|
@@ -1789,6 +1789,38 @@ public class MSBuildHelperTests : TestBase
|
|
1789
1789
|
new PrivateSourceAuthenticationFailure(["http://localhost/test-feed"]),
|
1790
1790
|
];
|
1791
1791
|
|
1792
|
+
yield return
|
1793
|
+
[
|
1794
|
+
// output
|
1795
|
+
"Response status code does not indicate success: 500 (Internal Server Error).",
|
1796
|
+
// expectedError
|
1797
|
+
new PrivateSourceBadResponse(["http://localhost/test-feed"]),
|
1798
|
+
];
|
1799
|
+
|
1800
|
+
yield return
|
1801
|
+
[
|
1802
|
+
// output
|
1803
|
+
"The response ended prematurely. (ResponseEnded)",
|
1804
|
+
// expectedError
|
1805
|
+
new PrivateSourceBadResponse(["http://localhost/test-feed"]),
|
1806
|
+
];
|
1807
|
+
|
1808
|
+
yield return
|
1809
|
+
[
|
1810
|
+
// output
|
1811
|
+
"The file is not a valid nupkg.",
|
1812
|
+
// expectedError
|
1813
|
+
new PrivateSourceBadResponse(["http://localhost/test-feed"]),
|
1814
|
+
];
|
1815
|
+
|
1816
|
+
yield return
|
1817
|
+
[
|
1818
|
+
// output
|
1819
|
+
"The content at 'http://localhost/test-feed/Packages(Id='Some.Package',Version='1.2.3')' is not valid XML.",
|
1820
|
+
// expectedError
|
1821
|
+
new PrivateSourceBadResponse(["http://localhost/test-feed"]),
|
1822
|
+
];
|
1823
|
+
|
1792
1824
|
yield return
|
1793
1825
|
[
|
1794
1826
|
// output
|
@@ -1829,6 +1861,14 @@ public class MSBuildHelperTests : TestBase
|
|
1829
1861
|
new DependencyNotFound("missing-sdk"),
|
1830
1862
|
];
|
1831
1863
|
|
1864
|
+
yield return
|
1865
|
+
[
|
1866
|
+
// output
|
1867
|
+
"Unable to find package 'Some.Package'. Existing packages must be restored before performing an install or update",
|
1868
|
+
// expectedError
|
1869
|
+
new DependencyNotFound("Some.Package"),
|
1870
|
+
];
|
1871
|
+
|
1832
1872
|
yield return
|
1833
1873
|
[
|
1834
1874
|
// output
|
@@ -1884,6 +1924,17 @@ public class MSBuildHelperTests : TestBase
|
|
1884
1924
|
// expectedError
|
1885
1925
|
new DependencyFileNotParseable("/path/to/packages.config", "Some error message."),
|
1886
1926
|
];
|
1927
|
+
|
1928
|
+
yield return
|
1929
|
+
[
|
1930
|
+
// output
|
1931
|
+
"""
|
1932
|
+
NuGet.Config is not valid XML. Path: '/path/to/NuGet.Config'.
|
1933
|
+
Some error message.
|
1934
|
+
""",
|
1935
|
+
// expectedError
|
1936
|
+
new DependencyFileNotParseable("/path/to/NuGet.Config", "Some error message."),
|
1937
|
+
];
|
1887
1938
|
}
|
1888
1939
|
|
1889
1940
|
public static IEnumerable<object[]> GetTopLevelPackageDependencyInfosTestData()
|
@@ -0,0 +1,42 @@
|
|
1
|
+
using NuGetUpdater.Core.Utilities;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Utilities;
|
6
|
+
|
7
|
+
public class MarkdownListBuilderTests
|
8
|
+
{
|
9
|
+
[Theory]
|
10
|
+
[MemberData(nameof(ListCreationTestData))]
|
11
|
+
public void ListCreation(object obj, string expected)
|
12
|
+
{
|
13
|
+
expected = expected.Replace("\r", "");
|
14
|
+
var actual = MarkdownListBuilder.FromObject(obj).Replace("\r", "");
|
15
|
+
Assert.Equal(expected, actual);
|
16
|
+
}
|
17
|
+
|
18
|
+
public static IEnumerable<object[]> ListCreationTestData()
|
19
|
+
{
|
20
|
+
yield return
|
21
|
+
[
|
22
|
+
new Dictionary<string, object>()
|
23
|
+
{
|
24
|
+
["key1"] = "value1",
|
25
|
+
["key2"] = new[]
|
26
|
+
{
|
27
|
+
new Dictionary<string, object>()
|
28
|
+
{
|
29
|
+
["key11"] = "value11",
|
30
|
+
["key12"] = "value12"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"""
|
35
|
+
- key1: value1
|
36
|
+
- key2:
|
37
|
+
- - key11: value11
|
38
|
+
- key12: value12
|
39
|
+
"""
|
40
|
+
];
|
41
|
+
}
|
42
|
+
}
|