private GitHubEndpoint(GitHubAction gitHubAction, GitHubEndpointAttribute gitHubEndpointAttribute) { ActionCode = (int)gitHubAction; ActionName = gitHubEndpointAttribute.Description; Method = gitHubEndpointAttribute.Method; Path = '/' + gitHubEndpointAttribute.Path; }
public void Service_Should_Be_Set_To_GitHubActions() { // Given var githubAction = new GitHubAction(); // When var service = githubAction.Service; // Then service.Should().Be("github-actions"); }
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(); }
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(); }
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"); }
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(); }
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"); }
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(); }
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(); }
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"); }
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(); }
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(); }
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(); }
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"); }
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(); }
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"); }
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(); }
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"); }
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"); }
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"); }
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(); }
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(); }
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(); }
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"); }
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"); }
public static GitHubEndpoint GetEndpoint(GitHubAction gitHubAction) => GetEndpoints(action => action == gitHubAction).FirstOrDefault();