Skip to content

Commit

Permalink
Make functional tests reuse packages they have uploaded if possible (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bommarito authored May 22, 2018
1 parent 26d3159 commit db760d2
Show file tree
Hide file tree
Showing 43 changed files with 439 additions and 2,479 deletions.
385 changes: 338 additions & 47 deletions tests/NuGetGallery.FunctionalTests.Core/Helpers/ClientSdkHelper.cs

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions tests/NuGetGallery.FunctionalTests.Core/Helpers/UploadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace NuGetGallery.FunctionalTests.Helpers
{
public static class UploadHelper
{
private static readonly object UniqueLock = new object();

/// <summary>
/// Helper class for defining the properties of a test package to be uploaded.
/// </summary>
Expand Down Expand Up @@ -48,23 +50,24 @@ protected PackageToUpload(PackageToUpload package)
/// <summary>
/// Gets a unique ID for a package to upload.
/// </summary>
public static string GetUniquePackageId(string test)
public static string GetUniquePackageId()
{
if (test == null)
lock (UniqueLock)
{
test = "UploadPackageFromUI";
return $"NuGetFunctionalTest_{DateTimeOffset.UtcNow.Ticks}";
}

return $"{test}_{DateTimeOffset.UtcNow.Ticks}";
}

/// <summary>
/// Gets a unique version for a package to upload.
/// </summary>
public static string GetUniquePackageVersion()
{
var ticks = DateTimeOffset.UtcNow.Ticks;
return $"1.0.0-v{ticks}";
lock (UniqueLock)
{
var ticks = DateTimeOffset.UtcNow.Ticks;
return $"1.0.0-v{ticks}";
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Net;
using System.Threading.Tasks;
using Xunit;

namespace NuGetGallery.FunctionalTests
{
Expand Down Expand Up @@ -48,7 +49,12 @@ public async Task CheckIfBaseTestPackageExistsAsync()
var clientSdkHelper = new ClientSdkHelper(ConsoleTestOutputHelper.New);
if (!clientSdkHelper.CheckIfPackageExistsInSource(Constants.TestPackageId, UrlHelper.V2FeedRootUrl))
{
await clientSdkHelper.UploadNewPackageAndVerify(Constants.TestPackageId);
var testOutputHelper = ConsoleTestOutputHelper.New;
var commandlineHelper = new CommandlineHelper(testOutputHelper);
var packageCreationHelper = new PackageCreationHelper(testOutputHelper);
var packageFullPath = await packageCreationHelper.CreatePackage(Constants.TestPackageId, "1.0.0");
var processResult = await commandlineHelper.UploadPackageAsync(packageFullPath, UrlHelper.V2FeedPushSourceUrl);
Assert.True(processResult.ExitCode == 0, Constants.UploadFailureMessage);
}
}
catch (Exception exception)
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit db760d2

Please sign in to comment.