Ejemplo n.º 1
0
 private GitHubEndpoint(GitHubAction gitHubAction, GitHubEndpointAttribute gitHubEndpointAttribute)
 {
     ActionCode = (int)gitHubAction;
     ActionName = gitHubEndpointAttribute.Description;
     Method     = gitHubEndpointAttribute.Method;
     Path       = '/' + gitHubEndpointAttribute.Path;
 }
Ejemplo n.º 2
0
        public void Service_Should_Be_Set_To_GitHubActions()
        {
            // Given
            var githubAction = new GitHubAction();

            // When
            var service = githubAction.Service;

            // Then
            service.Should().Be("github-actions");
        }
Ejemplo n.º 3
0
        public void Detecter_Should_Be_False_When_Action_Environment_Variable_Is_Null_Or_Empty()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var detecter = githubAction.Detecter;

            // Then
            detecter.Should().BeFalse();
        }
Ejemplo n.º 4
0
        public void Commit_Should_Be_Empty_String_When_Enviornment_Variable_Does_Not_Exits()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var commit = githubAction.Commit;

            // Then
            commit.Should().BeEmpty();
        }
Ejemplo n.º 5
0
        public void Commit_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_SHA", "123");
            var githubAction = new GitHubAction();

            // When
            var commit = githubAction.Commit;

            // Then
            commit.Should().Be("123");
        }
Ejemplo n.º 6
0
        public void Build_Should_Be_Empty_When_Environment_Variable_Does_Not_Exist()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var build = githubAction.Build;

            // Then
            build.Should().BeEmpty();
        }
Ejemplo n.º 7
0
        public void Branch_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_REF", "ref/heads/develop");
            var githubAction = new GitHubAction();

            // When
            var branch = githubAction.Branch;

            // Then
            branch.Should().Be("develop");
        }
Ejemplo n.º 8
0
        public void Commit_Should_Be_Empty_String_When_Enviornment_Variable_Does_Not_Exits()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_SHA", null);
            var githubAction = new GitHubAction();

            // When
            var commit = githubAction.Commit;

            // Then
            commit.Should().BeEmpty();
        }
Ejemplo n.º 9
0
        public void Slug_Should_Be_Empty_String_When_Environment_Variable_Does_Not_Exist()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_REPOSITORY", null);
            var githubAction = new GitHubAction();

            // When
            var slug = githubAction.Slug;

            // Then
            slug.Should().BeEmpty();
        }
Ejemplo n.º 10
0
        public void Slug_Should_Be_Set_When_Environment_Variable_Exist()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_REPOSITORY", "foo/bar");
            var githubAction = new GitHubAction();

            // When
            var slug = githubAction.Slug;

            // Then
            slug.Should().Be("foo/bar");
        }
Ejemplo n.º 11
0
        public void Detecter_Should_Be_True_When_Actions_Environment_Variable_Exist_And_Is_True(string environmentData)
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_ACTIONS", environmentData);
            var githubActions = new GitHubAction();

            // When
            var detecter = githubActions.Detecter;

            // Then
            detecter.Should().BeTrue();
        }
Ejemplo n.º 12
0
        public void Branch_Should_Be_Empty_When_Environment_Variable_Does_Not_Exist()
        {
            // Given
            Environment.SetEnvironmentVariable("GITHUB_REF", null);
            var githubAction = new GitHubAction();

            // When
            var branch = githubAction.Branch;

            // Then
            branch.Should().BeEmpty();
        }
Ejemplo n.º 13
0
        public void Slug_Should_Be_Empty_String_When_Environment_Variable_Does_Not_Exist()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var slug = githubAction.Slug;

            // Then
            slug.Should().BeEmpty();
        }
Ejemplo n.º 14
0
        public void Service_Should_Be_Set_To_GitHubActions()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var service = githubAction.Service;

            // Then
            service.Should().Be("github-actions");
        }
Ejemplo n.º 15
0
        public void PR_Should_Not_be_Set_If_Head_Ref_Is_Empyt()
        {
            // Given
            var ev           = new Mock <IEnviornmentVariables>();
            var githubAction = new GitHubAction(ev.Object);

            // When
            var pr = githubAction.Pr;

            // THen
            pr.Should().BeEmpty();
        }
Ejemplo n.º 16
0
        public void Slug_Should_Be_Set_When_Environment_Variable_Exist()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_REPOSITORY")).Returns("foo/bar");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var slug = githubAction.Slug;

            // Then
            slug.Should().Be("foo/bar");
        }
Ejemplo n.º 17
0
        public void BuildUrl_Should_Be_Empty_When_Build_Is_Empty()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_REPOSITORY")).Returns("codecov/codecov-exe");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var buildUrl = githubAction.BuildUrl;

            // Then
            buildUrl.Should().BeEmpty();
        }
Ejemplo n.º 18
0
        public void Build_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_RUN_ID")).Returns("32402849");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var build = githubAction.Build;

            // Then
            build.Should().Be("32402849");
        }
Ejemplo n.º 19
0
        public void Commit_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_SHA")).Returns("123");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var commit = githubAction.Commit;

            // Then
            commit.Should().Be("123");
        }
Ejemplo n.º 20
0
        public void Branch_Should_Be_Set_When_Enviornment_Variable_Exits()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_REF")).Returns("refs/heads/develop");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var branch = githubAction.Branch;

            // Then
            branch.Should().Be("develop");
        }
Ejemplo n.º 21
0
        public void Detecter_Should_Be_True_When_Action_Environment_Variable_Exist_And_Is_Not_Empty()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_ACTION")).Returns("my-awesome-github-action");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var detecter = githubAction.Detecter;

            // Then
            detecter.Should().BeTrue();
        }
Ejemplo n.º 22
0
        public void Detecter_Should_Be_True_When_Actions_Environment_Variable_Exist_And_Is_True(string environmentData)
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_ACTIONS")).Returns(environmentData);
            var githubAction = new GitHubAction(ev.Object);

            // When
            var detecter = githubAction.Detecter;

            // Then
            detecter.Should().BeTrue();
        }
Ejemplo n.º 23
0
        public void BuildUrl_Should_Be_Empty_When_Slug_Is_Empty()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_RUN_ID")).Returns("some-id");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var buildUrl = githubAction.BuildUrl;

            // Then
            buildUrl.Should().BeEmpty();
        }
Ejemplo n.º 24
0
        public void BuildUrl_Should_Not_Be_Empty_When_Environment_Variables_Exist()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_REPOSITORY")).Returns("codecov/codecov-exe");
            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_RUN_ID")).Returns("23432");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var buildUrl = githubAction.BuildUrl;

            // Then
            buildUrl.Should().Be("https://github.com/codecov/codecov-exe/actions/runs/23432");
        }
Ejemplo n.º 25
0
        public void PR_Should_Not_Be_Empty_When_Environment_Variables_Exist()
        {
            // Given
            var ev = new Mock <IEnviornmentVariables>();

            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_HEAD_REF")).Returns("patch-2");
            ev.Setup(s => s.GetEnvironmentVariable("GITHUB_REF")).Returns("refs/pull/7/merge");
            var githubAction = new GitHubAction(ev.Object);

            // When
            var pr     = githubAction.Pr;
            var branch = githubAction.Branch;

            // Then
            pr.Should().Be("7");
            branch.Should().Be("patch-2");
        }
Ejemplo n.º 26
0
 public static GitHubEndpoint GetEndpoint(GitHubAction gitHubAction) => GetEndpoints(action => action == gitHubAction).FirstOrDefault();