mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
This change adds a --folder parameter to both 'vpk upload az' and 'vpk download az' commands, allowing users to organize releases in subdirectories within their Azure blob containers. Key changes: - Added Folder property to AzureUploadOptions and AzureDownloadOptions - Modified AzureRepository to prepend folder paths to all blob operations - Updated upload, download, and delete operations to work with folder paths - Retention policy (--keepMaxReleases) correctly handles files in folders - Release index and legacy release files are stored in the specified folder This enables multiple applications or environments to share a single Azure container by using folders as isolated namespaces. For example: - vpk upload az --folder "releases/v1" ... - vpk download az --folder "releases/v1" ... The implementation is backward compatible - existing deployments without folders continue to work as before.
82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Velopack.Deployment;
|
|
using Velopack.Core;
|
|
using Xunit;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
namespace Velopack.Packaging.Tests;
|
|
|
|
public class AzureFolderTests
|
|
{
|
|
[Fact]
|
|
public void AzureRepository_UploadWithFolder_PrependsPathToKeys()
|
|
{
|
|
// This test verifies that when a folder is specified,
|
|
// all blob keys (filenames) are prepended with the folder path
|
|
|
|
var options = new AzureUploadOptions
|
|
{
|
|
Folder = "releases/v1",
|
|
Account = "testaccount",
|
|
Key = "testkey",
|
|
Container = "testcontainer"
|
|
};
|
|
|
|
Assert.Equal("releases/v1", options.Folder);
|
|
}
|
|
|
|
[Fact]
|
|
public void AzureRepository_DownloadWithFolder_PrependsPathToKeys()
|
|
{
|
|
// This test verifies that download options can have a folder
|
|
|
|
var options = new AzureDownloadOptions
|
|
{
|
|
Folder = "releases/v1",
|
|
Account = "testaccount",
|
|
Key = "testkey",
|
|
Container = "testcontainer"
|
|
};
|
|
|
|
Assert.Equal("releases/v1", options.Folder);
|
|
}
|
|
|
|
[Fact]
|
|
public void AzureRepository_FolderPath_NormalizesSlashes()
|
|
{
|
|
// Test that trailing slashes are handled correctly
|
|
var options1 = new AzureUploadOptions { Folder = "releases/v1/" };
|
|
var options2 = new AzureUploadOptions { Folder = "releases/v1" };
|
|
|
|
// Both should work correctly when used
|
|
Assert.Equal("releases/v1/", options1.Folder);
|
|
Assert.Equal("releases/v1", options2.Folder);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("releases/v1", "releases/v1/file.nupkg")]
|
|
[InlineData("releases/v1/", "releases/v1/file.nupkg")]
|
|
[InlineData("releases/v1//", "releases/v1/file.nupkg")]
|
|
[InlineData("/releases/v1", "/releases/v1/file.nupkg")]
|
|
[InlineData("", "file.nupkg")]
|
|
[InlineData(null, "file.nupkg")]
|
|
public void AzureRepository_FolderPath_ProducesCorrectBlobKey(string folder, string expectedKey)
|
|
{
|
|
// Test the logic we use to combine folder and filename
|
|
string filename = "file.nupkg";
|
|
string result;
|
|
|
|
if (!string.IsNullOrEmpty(folder))
|
|
{
|
|
result = folder.TrimEnd('/') + "/" + filename;
|
|
}
|
|
else
|
|
{
|
|
result = filename;
|
|
}
|
|
|
|
Assert.Equal(expectedKey, result);
|
|
}
|
|
|
|
} |