|
13 | 13 | using Microsoft.Web.LibraryManager.Mocks;
|
14 | 14 | using Microsoft.Web.LibraryManager.Providers.Cdnjs;
|
15 | 15 | using Microsoft.Web.LibraryManager.Providers.FileSystem;
|
16 |
| -using Microsoft.Web.LibraryManager.Providers.Unpkg; |
17 | 16 | using Microsoft.Web.LibraryManager.Providers.jsDelivr;
|
| 17 | +using Microsoft.Web.LibraryManager.Providers.Unpkg; |
| 18 | +using Microsoft.Web.LibraryManager.Test.TestUtilities; |
18 | 19 | using Moq;
|
19 | 20 |
|
20 | 21 | namespace Microsoft.Web.LibraryManager.Test
|
@@ -44,8 +45,9 @@ public void Setup()
|
44 | 45 | [TestMethod]
|
45 | 46 | public async Task DetectConflictsAsync_ConflictingFiles_SameDestination()
|
46 | 47 | {
|
| 48 | + string conflictFilePath = Path.Combine(_dependencies.GetHostInteractions().WorkingDirectory, "lib", "package.json"); |
47 | 49 | string expectedErrorCode = "LIB016";
|
48 |
| - string expectedErrorMessage = "Conflicting file \"lib\\package.json\" found in more than one library: jquery, d3"; |
| 50 | + string expectedErrorMessage = $"Conflicting file \"{conflictFilePath}\" found in more than one library: jquery, d3"; |
49 | 51 | var manifest = Manifest.FromJson(_docDifferentLibraries_SameFiles_SameLocation, _dependencies);
|
50 | 52 |
|
51 | 53 | IEnumerable<OperationResult<LibraryInstallationGoalState>> conflicts = await LibrariesValidator.GetManifestErrorsAsync(manifest, _dependencies, CancellationToken.None);
|
@@ -92,11 +94,10 @@ public async Task DetectConflictsAsync_SameLibrary_DifferentProviders()
|
92 | 94 |
|
93 | 95 | IEnumerable<OperationResult<LibraryInstallationGoalState>> results = await LibrariesValidator.GetManifestErrorsAsync(manifest, _dependencies, CancellationToken.None);
|
94 | 96 |
|
95 |
| - var conflictsList = results.ToList(); |
| 97 | + var conflictsList = results.Where(r => r.Errors?.Count > 0).ToList(); |
96 | 98 | Assert.AreEqual(1, conflictsList.Count);
|
97 |
| - Assert.IsTrue(conflictsList[0].Errors.Count == 1); |
98 |
| - Assert.AreEqual(conflictsList[0].Errors[0].Code, expectedErrorCode); |
99 |
| - Assert.AreEqual(conflictsList[0].Errors[0].Message, expectedErrorMessage); |
| 99 | + List<IError> expectedErrors = [new Contracts.Error(expectedErrorCode, expectedErrorMessage)]; |
| 100 | + Assert.That.ErrorsEqual(expectedErrors, conflictsList[0].Errors); |
100 | 101 | }
|
101 | 102 |
|
102 | 103 | [TestMethod]
|
@@ -244,7 +245,7 @@ public async Task GetLibrariesErrors_LibrariesNoProvider()
|
244 | 245 | ""{ManifestConstants.Library}"": ""[email protected]"",
|
245 | 246 | ""{ManifestConstants.Provider}"": ""unpkg"",
|
246 | 247 | ""{ManifestConstants.Destination}"": ""lib2"",
|
247 |
| - ""{ManifestConstants.Files}"": [ ""jquery.js"" ] |
| 248 | + ""{ManifestConstants.Files}"": [ ""dist/jquery.js"" ] |
248 | 249 | }},
|
249 | 250 | ]
|
250 | 251 | }}
|
|
0 commit comments