public async Task Should_Upload(string workingDirectory, string testPath) { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture() .WithWorkingDirectory(workingDirectory); var testDirectoryPath = DirectoryPath.FromString(testPath); var artifactName = "artifacts"; var directory = DirectoryPath.FromString("/src/artifacts"); gitHubActionsCommandsFixture .FileSystem .CreateFile(directory.CombineWithFilePath("artifact.txt")) .SetContent(artifactName); gitHubActionsCommandsFixture .FileSystem .CreateFile(directory.Combine("folder_a").CombineWithFilePath("artifact.txt")) .SetContent(artifactName); gitHubActionsCommandsFixture .FileSystem .CreateFile(directory.Combine("folder_b").CombineWithFilePath("artifact.txt")) .SetContent(artifactName); gitHubActionsCommandsFixture .FileSystem .CreateFile(directory.Combine("folder_b").Combine("folder_c").CombineWithFilePath("artifact.txt")) .SetContent(artifactName); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); // When await commands.UploadArtifact(testDirectoryPath, artifactName); }
public async Task Should_Download(string workingDirectory, string testPath) { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture() .WithWorkingDirectory(workingDirectory); var testDirectoryPath = DirectoryPath.FromString(testPath); var artifactName = "artifact"; var directory = DirectoryPath.FromString("/src/artifacts"); var filePath = directory.CombineWithFilePath("test.txt"); gitHubActionsCommandsFixture .FileSystem .CreateDirectory(directory); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); // When await commands.DownloadArtifact(artifactName, testDirectoryPath); var file = gitHubActionsCommandsFixture .FileSystem .GetFile(filePath); // Then Assert.True(file.Exists, $"{filePath.FullPath} doesn't exist."); Assert.Equal("Cake", file.GetTextContent()); }
public void Should_Throw_If_Path_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); // When var result = Record.Exception(() => commands.AddPath(null)); // Then AssertEx.IsArgumentNullException(result, "path"); }
public void Should_Throw_If_Key_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); // When var result = Record.Exception(() => commands.SetEnvironmentVariable(null, null)); // Then AssertEx.IsArgumentNullException(result, "key"); }
public async Task Should_Throw_If_Path_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); var artifactName = "artifactName"; // When var result = await Record.ExceptionAsync(() => commands.DownloadArtifact(artifactName, null)); // Then AssertEx.IsArgumentNullException(result, "path"); }
public async Task Should_Throw_If_ArtifactName_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); var path = DirectoryPath.FromString("/artifacts"); // When var result = await Record.ExceptionAsync(() => commands.DownloadArtifact(null, path)); // Then AssertEx.IsArgumentNullException(result, "artifactName"); }
public async Task Should_Throw_If_Path_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); DirectoryPath path = null; // When var result = await Record.ExceptionAsync(() => commands.UploadArtifact(path, null)); // Then AssertEx.IsArgumentNullException(result, "path"); }
public async Task Should_Throw_If_Directory_Missing() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); var path = DirectoryPath.FromString("/artifacts"); var artifactName = "artifact"; // When var result = await Record.ExceptionAsync(() => commands.DownloadArtifact(artifactName, path)); // Then AssertEx.IsExceptionWithMessage <DirectoryNotFoundException>(result, "Local directory /artifacts not found."); }
public async Task Should_Throw_If_File_Missing() { // Given var commands = new GitHubActionsCommandsFixture().CreateGitHubActionsCommands(); var path = FilePath.FromString("/artifacts/artifact.zip"); var artifactName = "artifact"; // When var result = await Record.ExceptionAsync(() => commands.UploadArtifact(path, artifactName)); // Then AssertEx.IsExceptionWithMessage <FileNotFoundException>(result, "Artifact file not found."); }
public async Task Should_Upload() { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture(); var artifactName = "artifact"; var file = gitHubActionsCommandsFixture .FileSystem .CreateFile("/artifacts/artifact.txt") .SetContent(artifactName); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); // When await commands.UploadArtifact(file.Path, artifactName); }
public void Should_Throw_If_SystemPath_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture() .WithNoGitHubPath() .CreateGitHubActionsCommands(); var path = "/temp/dev/bin"; // When var result = Record.Exception(() => commands.AddPath(path)); // Then AssertEx.IsCakeException(result, "GitHub Actions Runtime SystemPath missing."); }
public void Should_AddPath() { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture(); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); var path = "/temp/dev/bin"; // When commands.AddPath(path); // Then Assert.Equal( (path + System.Environment.NewLine).NormalizeLineEndings(), gitHubActionsCommandsFixture.FileSystem.GetFile("/opt/github.path").GetTextContent().NormalizeLineEndings()); }
public void Should_Throw_If_EnvPath_Is_Null() { // Given var commands = new GitHubActionsCommandsFixture() .WithNoGitHubEnv() .CreateGitHubActionsCommands(); var key = "Key"; var value = "Value"; // When var result = Record.Exception(() => commands.SetEnvironmentVariable(key, value)); // Then AssertEx.IsCakeException(result, "GitHub Actions Runtime EnvPath missing."); }
public async Task Should_Upload(string workingDirectory, string testPath) { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture() .WithWorkingDirectory(workingDirectory); var testFilePath = FilePath.FromString(testPath); var artifactName = "artifact"; gitHubActionsCommandsFixture .FileSystem .CreateFile("/artifacts/artifact.txt") .SetContent(artifactName); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); // When await commands.UploadArtifact(testFilePath, artifactName); }
public void Should_SetEnvironmentVariable() { // Given var gitHubActionsCommandsFixture = new GitHubActionsCommandsFixture(); var commands = gitHubActionsCommandsFixture.CreateGitHubActionsCommands(); var key = "Key"; var value = "Value"; // When commands.SetEnvironmentVariable(key, value); // Then Assert.Equal( @"Key<<CAKEEOF Value CAKEEOF ".NormalizeLineEndings(), gitHubActionsCommandsFixture.FileSystem.GetFile("/opt/github.env").GetTextContent().NormalizeLineEndings()); }