public async Task GetLatestVersion_LatestExist() { const string libraryId = "[email protected]"; Mocks.WebRequestHandler fakeHandler = new Mocks.WebRequestHandler().SetupVersions("fakeLib", "fake/fakeLib"); JsDelivrCatalog sut = SetupCatalog(fakeHandler); string result = await sut.GetLatestVersion(libraryId, false, CancellationToken.None); Assert.AreEqual("1.0.0", result); // TODO: A new test should be added for when the tags are missing. This is passing because the fake // data is as expected. However, real data does not include the tags and would return null. // The original test implementation checked for null and didn't assert anything in that case. const string libraryIdGH = "fake/[email protected]"; string resultGH = await sut.GetLatestVersion(libraryIdGH, false, CancellationToken.None); Assert.AreEqual("1.0.0", resultGH); }
[Ignore] // TODO: GetLatestVersion currently only looks for the stable tag. public async Task GetLatestVersion_PreRelease() { const string libraryId = "[email protected]"; Mocks.WebRequestHandler fakeHandler = new Mocks.WebRequestHandler().SetupVersions("fakeLib", "fake/fakeLib"); JsDelivrCatalog sut = SetupCatalog(fakeHandler); string result = await sut.GetLatestVersion(libraryId, true, CancellationToken.None); Assert.AreEqual("2.0.0-beta", result); }
public async Task GetLatestVersion_CacheRequestFails_ReturnsNull() { var fakeCacheService = new Mock <ICacheService>(); fakeCacheService.SetupBlockRequests(); JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCacheService.Object); string result = await sut.GetLatestVersion("fakeLibrary", false, CancellationToken.None); Assert.IsNull(result); }
public async Task GetLatestVersion_Git_Prerelease() { const string libraryId = "fakeLib/[email protected]"; var fakeCache = new Mock <ICacheService>(); fakeCache.SetupGitHubLibraryVersions("fakeLib/fakeLib"); JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCache.Object); string result = await sut.GetLatestVersion(libraryId, true, CancellationToken.None); Assert.AreEqual("2.0.0-prerelease", result); }
public async Task GetLatestVersion_GitHub_ParseVersionsList() { var fakeCache = new Mock <ICacheService>(); fakeCache.SetupGitHubLibraryVersions("fake/fakeLib"); JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCache.Object); const string libraryIdGH = "fake/[email protected]"; string resultGH = await sut.GetLatestVersion(libraryIdGH, false, CancellationToken.None); Assert.AreEqual("1.2.3", resultGH); }
public async Task GetLatestVersion_LatestExist() { const string libraryId = "[email protected]"; var fakeCache = new Mock <ICacheService>(); fakeCache.SetupNpmLibraryVersions("fakeLib"); JsDelivrCatalog sut = SetupCatalog(cacheService: fakeCache.Object); string result = await sut.GetLatestVersion(libraryId, false, CancellationToken.None); Assert.AreEqual("1.0.0", result); }