mirror of https://github.com/dotnet/tye.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
3.0 KiB
68 lines
3.0 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Testing;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.Tye.UnitTests
|
|
{
|
|
public class FuncFinderTests : LoggedTest
|
|
{
|
|
[Theory]
|
|
[InlineData("v2", "x64", "2.")]
|
|
[InlineData("v3", "x64", "3.")]
|
|
public async Task FuncInstallerReturnsRightPaths(string version, string arch, string expectedVersionPart)
|
|
{
|
|
var funcDownloader = new FuncDetector();
|
|
var path = await funcDownloader.PathToFunc(version, arch, downloadPath: null, logger: LoggerFactory.CreateLogger("AzureFunctionTest"), default, dryRun: true);
|
|
|
|
// Verifying this path is a bit tricky, version isn't easily associated.
|
|
// Using partial matches
|
|
//Assert.Contains(FuncDetector.GetAzureFunctionDirectory(), path);
|
|
Assert.Contains(expectedVersionPart, path);
|
|
}
|
|
|
|
[ConditionalTheory]
|
|
[OSSkipCondition(OperatingSystems.Linux)]
|
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
|
[InlineData("v2", "x86", "2.")]
|
|
[InlineData("v3", "x86", "3.")]
|
|
public async Task FuncInstallerReturnsRightPathsWindows(string version, string arch, string expectedVersionPart)
|
|
{
|
|
var funcDownloader = new FuncDetector();
|
|
var path = await funcDownloader.PathToFunc(version, arch, downloadPath: null, logger: LoggerFactory.CreateLogger("AzureFunctionTest"), default, dryRun: true);
|
|
|
|
// Verifying this path is a bit tricky, version isn't easily associated.
|
|
// Using partial matches
|
|
//Assert.Contains(FuncDetector.GetAzureFunctionDirectory(), path);
|
|
Assert.Contains(expectedVersionPart, path);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task FuncInstallerWritesToDifferentDirectory()
|
|
{
|
|
using var tmp = TempDirectory.Create();
|
|
var funcDownloader = new FuncDetector();
|
|
var path = await funcDownloader.PathToFunc("v3", "x64", tmp.DirectoryPath, logger: LoggerFactory.CreateLogger("AzureFunctionTest"), default, dryRun: true);
|
|
|
|
Assert.Contains(tmp.DirectoryPath, path);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task FuncInstallerLogsForV1SayingUnsupported()
|
|
{
|
|
var logger = LoggerFactory.CreateLogger("AzureFunctionTest");
|
|
var funcDownloader = new FuncDetector();
|
|
var path = await funcDownloader.PathToFunc("v1", "x64", downloadPath: null, logger: logger, default, dryRun: true);
|
|
Assert.Contains(TestSink.Writes, context => context.Message.Contains("Functions V1 are unsupported and untested in Tye."));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task FuncInstallerThrowsForInvalidArch()
|
|
{
|
|
var funcDownloader = new FuncDetector();
|
|
await Assert.ThrowsAsync<NotSupportedException>(async () =>
|
|
await funcDownloader.PathToFunc("v3", "x64a", downloadPath: null, logger: LoggerFactory.CreateLogger("AzureFunctionTest"), default, dryRun: true));
|
|
}
|
|
|
|
}
|
|
}
|
|
|