public async Task WritesToReplicaHives() { ReplicaHives.Add(HiveType.Gzipped); ReplicaHives.Add(HiveType.SemVer2); await Target.WriteIndexAsync(Hive, ReplicaHives, Id, Index); LegacyBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once); GzippedBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once); SemVer2Blob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once); EntityBuilder.Verify(x => x.UpdateIndexUrls(It.IsAny <RegistrationIndex>(), It.IsAny <HiveType>(), It.IsAny <HiveType>()), Times.Exactly(3)); EntityBuilder.Verify(x => x.UpdateIndexUrls(Index, HiveType.Legacy, HiveType.Gzipped), Times.Once); EntityBuilder.Verify(x => x.UpdateIndexUrls(Index, HiveType.Gzipped, HiveType.SemVer2), Times.Once); EntityBuilder.Verify(x => x.UpdateIndexUrls(Index, HiveType.SemVer2, HiveType.Legacy), Times.Once); }
public async Task ThrowsFor404() { var expected = new StorageException( new RequestResult { HttpStatusCode = (int)HttpStatusCode.NotFound }, "Missing.", inner: null); LegacyBlob.Setup(x => x.OpenReadAsync(It.IsAny <AccessCondition>())).Throws(expected); var url = "https://example/reg/nuget.versioning/0.0.1/0.0.2.json"; var actual = await Assert.ThrowsAsync <StorageException>( () => Target.ReadPageAsync(HiveType.Legacy, url)); Assert.Same(expected, actual); }
public async Task DoesNotListOrSnapshotBlobWhenNotConfiguredToSnapshot() { Config.EnsureSingleSnapshot = false; await Target.WriteIndexAsync(Hive, ReplicaHives, Id, Index); LegacyBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once); LegacyContainer.Verify( x => x.ListBlobsSegmentedAsync( It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <BlobListingDetails>(), It.IsAny <int?>(), It.IsAny <BlobContinuationToken>(), It.IsAny <BlobRequestOptions>(), It.IsAny <OperationContext>(), It.IsAny <CancellationToken>()), Times.Never); LegacyBlob.Verify(x => x.SnapshotAsync(It.IsAny <CancellationToken>()), Times.Never); }
public async Task DoesNotSnapshotBlobWhenConfiguredAndAlreadyHasSnapshot() { Config.EnsureSingleSnapshot = true; LegacySegment.Setup(x => x.Results).Returns(() => new[] { LegacyBlob.Object, LegacyBlob.Object }); await Target.WriteIndexAsync(Hive, ReplicaHives, Id, Index); LegacyBlob.Verify(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>()), Times.Once); LegacyContainer.Verify( x => x.ListBlobsSegmentedAsync( "nuget.versioning/index.json", true, BlobListingDetails.Snapshots, 2, null, null, null, It.IsAny <CancellationToken>()), Times.Once); LegacyBlob.Verify(x => x.SnapshotAsync(It.IsAny <CancellationToken>()), Times.Never); }