Ejemplo n.º 1
0
                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);
                }
Ejemplo n.º 2
0
            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());
            }
Ejemplo n.º 3
0
            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");
            }
Ejemplo n.º 4
0
            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");
            }
Ejemplo n.º 5
0
            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");
            }
Ejemplo n.º 6
0
            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");
            }
Ejemplo n.º 7
0
                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");
                }
Ejemplo n.º 8
0
            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.");
            }
Ejemplo n.º 9
0
                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.");
                }
Ejemplo n.º 10
0
                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);
                }
Ejemplo n.º 11
0
            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.");
            }
Ejemplo n.º 12
0
            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());
            }
Ejemplo n.º 13
0
            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.");
            }
Ejemplo n.º 14
0
                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);
                }
Ejemplo n.º 15
0
            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());
            }