Beispiel #1
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 TestPackages.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 = 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());
                }
        }