示例#1
0
        public async Task PushToServerWhichRejectsDuplicates_SkipDuplicate_Succeeds(PackageSource packageSource)
        {
            // Arrange
            using (var packageDir = TestDirectory.Create())
                using (TestFileSystemUtility.SetCurrentDirectory(packageDir))
                {
                    var packageId      = "XPlatPushTests.PushToServerSucceeds";
                    var packageVersion = "1.0.0";
                    var packageFile    = await TestPackagesCore.GetRuntimePackageAsync(packageDir, packageId, packageVersion);

                    var configFile    = XPlatTestUtils.CopyFuncTestConfig(packageDir);
                    var logFirstPush  = new TestCommandOutputLogger();
                    var logSecondPush = new TestCommandOutputLogger();

                    var apiKey = XPlatTestUtils.ReadApiKey(packageSource.Name);
                    Assert.False(string.IsNullOrEmpty(apiKey));
                    var pushArgs = new List <string>
                    {
                        "push",
                        packageFile.FullName,
                        "--source",
                        packageSource.Source,
                        "--api-key",
                        apiKey,
                        "--skip-duplicate"
                    };

                    // Act
                    var exitCodeFirstPush  = NuGet.CommandLine.XPlat.Program.MainInternal(pushArgs.ToArray(), logFirstPush);
                    var exitCodeSecondPush = NuGet.CommandLine.XPlat.Program.MainInternal(pushArgs.ToArray(), logSecondPush);

                    // Assert First Push - it should happen without error.
                    var outputMessagesFirstPush = logFirstPush.ShowMessages();
                    Assert.Equal(string.Empty, logFirstPush.ShowErrors());
                    Assert.Equal(0, exitCodeFirstPush);

                    // Assert Second Push - it should happen without error, even though a duplicate is present.
                    var outputMessagesSecondPush = logSecondPush.ShowMessages();

                    Assert.Equal(string.Empty, logSecondPush.ShowErrors());
                    Assert.Equal(0, exitCodeSecondPush);
                    Assert.Contains($"PUT {packageSource.Source}", outputMessagesSecondPush);
                    Assert.DoesNotContain("already exists at feed", outputMessagesSecondPush);
                    Assert.Contains("Your package was pushed.", outputMessagesSecondPush);
                }
        }
示例#2
0
        public async Task PushToServerSkipDuplicateSucceeds(PackageSource packageSource)
        {
            // Arrange
            using (var packageDir = TestDirectory.Create())
                using (TestFileSystemUtility.SetCurrentDirectory(packageDir))
                {
                    var packageId      = "XPlatPushTests.PushToServerSucceeds";
                    var packageVersion = "1.0.0";
                    var packageFile    = await TestPackagesCore.GetRuntimePackageAsync(packageDir, packageId, packageVersion);

                    var configFile = XPlatTestUtils.CopyFuncTestConfig(packageDir);
                    var log        = new TestCommandOutputLogger();

                    var apiKey = XPlatTestUtils.ReadApiKey(packageSource.Name);
                    Assert.False(string.IsNullOrEmpty(apiKey));

                    var pushArgs = new List <string>
                    {
                        "push",
                        packageFile.FullName,
                        "--source",
                        packageSource.Source,
                        "--api-key",
                        apiKey,
                        "--skip-duplicate"
                    };

                    // Act
                    var exitCode = NuGet.CommandLine.XPlat.Program.MainInternal(pushArgs.ToArray(), log);

                    // Assert
                    var outputMessages = log.ShowMessages();

                    Assert.Equal(string.Empty, log.ShowErrors());
                    Assert.Equal(0, exitCode);
                    Assert.Contains($"PUT {packageSource.Source}", outputMessages);


                    //info: PUT http://localhost:5000/api/v2/package/
                    //info: Conflict http://localhost:5000/api/v2/package/ 127ms
                    Assert.Contains("already exists at feed", outputMessages);
                    Assert.Contains("Your package was pushed.", outputMessages);
                }
        }
示例#3
0
        // [InlineData(TestServers.Klondike, nameof(TestServers.Klondike), false)] // 500 Internal Server Error pushing
        // [InlineData(TestServers.NuGetServer, nameof(TestServers.NuGetServer), false)] // 500 - missing manifest?
        public async Task PushToServerSucceeds(string sourceUri, string feedName, bool mustDeleteFirst)
        {
            // Arrange
            using (var packageDir = TestDirectory.Create())
                using (TestFileSystemUtility.SetCurrentDirectory(packageDir))
                {
                    var packageId      = "XPlatPushTests.PushToServerSucceeds";
                    var packageVersion = "1.0.0";
                    var packageFile    = await TestPackagesCore.GetRuntimePackageAsync(packageDir, packageId, packageVersion);

                    var configFile = XPlatTestUtils.CopyFuncTestConfig(packageDir);
                    var log        = new TestCommandOutputLogger();

                    var apiKey = XPlatTestUtils.ReadApiKey(feedName);
                    Assert.False(string.IsNullOrEmpty(apiKey));

                    if (mustDeleteFirst)
                    {
                        DeletePackageBeforePush(packageId, packageVersion, sourceUri, apiKey);
                    }

                    var pushArgs = new List <string>()
                    {
                        "push",
                        packageFile.FullName,
                        "--source",
                        sourceUri,
                        "--api-key",
                        apiKey
                    };

                    // Act
                    int exitCode = NuGet.CommandLine.XPlat.Program.MainInternal(pushArgs.ToArray(), log);

                    // Assert
                    Assert.Equal(string.Empty, log.ShowErrors());
                    Assert.Equal(0, exitCode);
                    Assert.Contains($"PUT {sourceUri}", log.ShowMessages());
                    Assert.Contains("Your package was pushed.", log.ShowMessages());
                }
        }