Beispiel #1
0
        public async Task CleanupAsync()
        {
            cleanupDone = true;

            if (await Client.DoesS3BucketExistAsync(BucketName))
            {
                var s3Objects = (await AmazonS3FileSystemAbstraction
                                 .GetFilesAsync(Client, BucketName, CancellationToken.None))
                                .Select(x => new KeyVersion {
                    Key = x.Key
                })
                                .ToArray();

                if (s3Objects.Any())
                {
                    await AmazonS3FileSystemAbstraction.RemoveMultipleFilesAsync(
                        Client,
                        BucketName,
                        s3Objects,
                        CancellationToken.None);
                }

                await Client.DeleteBucketAsync(BucketName);
            }
        }
Beispiel #2
0
        public async Task SubFeed_PushAndVerifyNoFilesInRoot()
        {
            using (var packagesFolder = new TestFolder())
                using (var testContext = new AmazonS3TestContext())
                {
                    // Use a subfeed for the filesystem
                    var subFeedName = "testSubFeed";
                    var root        = UriUtility.GetPath(testContext.Uri, subFeedName);
                    testContext.FileSystem = new AmazonS3FileSystem(
                        testContext.LocalCache, root, root,
                        testContext.Client, testContext.BucketName,
                        ServerSideEncryptionMethod.None, feedSubPath: subFeedName
                        );

                    await testContext.InitAsync();

                    var testPackage = new TestNupkg("packageA", "1.0.0");
                    var zipFile     = testPackage.Save(packagesFolder.Root);

                    var result = await InitCommand.RunAsync(testContext.LocalSettings,
                                                            testContext.FileSystem,
                                                            enableCatalog : true,
                                                            enableSymbols : true,
                                                            log : testContext.Logger,
                                                            token : CancellationToken.None);

                    result &= await PushCommand.RunAsync(testContext.LocalSettings,
                                                         testContext.FileSystem,
                                                         new List <string>() { zipFile.FullName },
                                                         force : false,
                                                         skipExisting : false,
                                                         log : testContext.Logger);

                    result &= await ValidateCommand.RunAsync(testContext.LocalSettings,
                                                             testContext.FileSystem,
                                                             testContext.Logger);

                    result.Should().BeTrue();

                    var files = await AmazonS3FileSystemAbstraction.GetFilesAsync(testContext.Client, testContext.BucketName, CancellationToken.None);

                    files.Where(e => e.Key.IndexOf(subFeedName, StringComparison.OrdinalIgnoreCase) < 0).Should().BeEmpty();
                    files.Where(e => e.Key.IndexOf(subFeedName, StringComparison.OrdinalIgnoreCase) > -1).Should().NotBeEmpty();

                    await testContext.CleanupAsync();
                }
        }