public async Task PutsSemVer2PackagesInLegacyStorageWhenSemVer2IsDisabled() { // Arrange SharedInit(useLegacy: true, useSemVer2: false); var catalogStorage = Catalogs.CreateTestCatalogWithSemVer2Package(); await _mockServer.AddStorageAsync(catalogStorage); var front = new DurableCursor(_legacyStorage.ResolveUri("cursor.json"), _legacyStorage, MemoryCursor.MinValue); var back = MemoryCursor.CreateMax(); // Act await _target.RunAsync(front, back, CancellationToken.None); // Assert var legacyCursor = _legacyStorage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("cursor.json")); Assert.NotNull(legacyCursor.Key); var legacyIndex = _legacyStorage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/testpackage.semver2/index.json")); Assert.NotNull(legacyIndex.Key); var legacyLeaf = _legacyStorage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/testpackage.semver2/1.0.0-alpha.1.json")); Assert.NotNull(legacyLeaf.Key); Assert.Equal(3, _legacyStorage.Content.Count); }
public async Task CreatesRegistrationsWithSemVer2() { // Arrange SharedInit(useLegacy: true, useSemVer2: true); var catalogStorage = Catalogs.CreateTestCatalogWithSemVer2Package(); await _mockServer.AddStorageAsync(catalogStorage); var front = new DurableCursor(_legacyStorage.ResolveUri("cursor.json"), _legacyStorage, MemoryCursor.MinValue); var back = MemoryCursor.CreateMax(); // Act await _target.RunAsync(front, back, CancellationToken.None); // Assert // Verify the contents of the legacy (non-SemVer 2.0.0) storage Assert.Equal(1, _legacyStorage.Content.Count); var legacyCursorJson = _legacyStorage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("cursor.json")); Assert.NotNull(legacyCursorJson.Key); // Verify the contents of the SemVer 2.0.0 storage Assert.Equal(2, _semVer2Storage.Content.Count); var semVer2CursorJson = _semVer2Storage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("cursor.json")); Assert.Null(semVer2CursorJson.Key); var index = _semVer2Storage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/testpackage.semver2/index.json")); Assert.NotNull(index.Key); Assert.Contains("\"catalog:CatalogRoot\"", index.Value.GetContentString()); Assert.Contains("\"PackageRegistration\"", index.Value.GetContentString()); Assert.Contains("\"http://tempuri.org/data/2015.10.12.10.08.54/testpackage.semver2.1.0.0-alpha.1.json\"", index.Value.GetContentString()); Assert.Contains("\"http://tempuri.org/packages/testpackage.semver2.1.0.0-alpha.1.nupkg\"", index.Value.GetContentString()); Assert.Contains("\"version\":\"1.0.0-alpha.1+githash\"", index.Value.GetContentString()); Assert.Contains("1.0.0-alpha.1/1.0.0-alpha.1", index.Value.GetContentString()); Assert.Contains("\"lower\":\"1.0.0-alpha.1\",", index.Value.GetContentString()); Assert.Contains("\"upper\":\"1.0.0-alpha.1\"", index.Value.GetContentString()); var package = _semVer2Storage.Content.FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/testpackage.semver2/1.0.0-alpha.1.json")); Assert.NotNull(package.Key); Assert.Contains("\"Package\"", package.Value.GetContentString()); Assert.Contains("\"http://tempuri.org/data/2015.10.12.10.08.54/testpackage.semver2.1.0.0-alpha.1.json\"", package.Value.GetContentString()); Assert.Contains("\"http://tempuri.org/packages/testpackage.semver2.1.0.0-alpha.1.nupkg\"", package.Value.GetContentString()); Assert.Contains("\"http://tempuri.org/testpackage.semver2/index.json\"", package.Value.GetContentString()); }