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 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_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_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 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()); }