-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68b7f8e
commit 24795ec
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/PackagingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using Xunit; | ||
|
||
namespace Amazon.Lambda.TestTool.UnitTests; | ||
|
||
public class PackagingTests | ||
{ | ||
[Fact] | ||
public void VerifyPackageContentsHasRuntimeSupport() | ||
{ | ||
string projectPath = Path.Combine(FindSolutionRoot(), "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj"); | ||
|
||
var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "dotnet", | ||
Arguments = $"pack {projectPath} -c Release", | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
process.Start(); | ||
string output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
Assert.Equal(0, process.ExitCode); | ||
|
||
string packagePath = Directory.GetFiles(Path.GetDirectoryName(projectPath), "*.nupkg", SearchOption.AllDirectories)[0]; | ||
|
||
using (var archive = ZipFile.OpenRead(packagePath)) | ||
{ | ||
var runtimeSupportDllEntry = archive.GetEntry("content/Amazon.Lambda.RuntimeSupport.dll"); | ||
Assert.NotNull(runtimeSupportDllEntry); | ||
} | ||
} | ||
|
||
private string FindSolutionRoot() | ||
{ | ||
string currentDirectory = Directory.GetCurrentDirectory(); | ||
while (currentDirectory != null) | ||
{ | ||
string[] solutionFiles = Directory.GetFiles(currentDirectory, "*.sln"); | ||
if (solutionFiles.Length > 0) | ||
{ | ||
return currentDirectory; | ||
} | ||
currentDirectory = Directory.GetParent(currentDirectory)?.FullName; | ||
} | ||
throw new Exception("Could not find the solution root directory."); | ||
} | ||
|
||
|
||
} |