Ejemplo n.º 1
0
        public void ShouldWriteIntegration()
        {
            // Arrange
            var buildServer = new GitHubActions(environment, log);

            var vars = new TestableVersionVariables("1.0.0");

            var list = new List <string>();

            // Assert
            environment.GetEnvironmentVariable("GitVersion_Major").ShouldBeNullOrWhiteSpace();

            // Act
            buildServer.WriteIntegration(s => { list.Add(s); }, vars);

            // Assert
            var expected = new List <string>
            {
                "Executing GenerateSetVersionMessage for 'GitHubActions'.",
                "",
                "Executing GenerateBuildLogOutput for 'GitHubActions'.",
                "::set-env name=GitVersion_Major::1.0.0"
            };

            string.Join(Environment.NewLine, list)
            .ShouldBe(string.Join(Environment.NewLine, expected));
        }
Ejemplo n.º 2
0
    public void SetUp()
    {
        var sp = ConfigureServices(services => services.AddSingleton <GitHubActions>());

        this.environment = sp.GetRequiredService <IEnvironment>();
        this.buildServer = sp.GetRequiredService <GitHubActions>();
        this.environment.SetEnvironmentVariable(GitHubActions.EnvironmentVariableName, "true");

        this.githubSetEnvironmentTempFilePath = Path.GetTempFileName();
        this.environment.SetEnvironmentVariable(GitHubActions.GitHubSetEnvTempFileEnvironmentVariableName, this.githubSetEnvironmentTempFilePath);
    }
Ejemplo n.º 3
0
        public void SetUp()
        {
            var sp = ConfigureServices(services =>
            {
                services.AddSingleton <GitHubActions>();
            });

            environment = sp.GetService <IEnvironment>();
            buildServer = sp.GetService <GitHubActions>();
            environment.SetEnvironmentVariable(GitHubActions.EnvironmentVariableName, "true");
        }
Ejemplo n.º 4
0
        public void CanApplyToCurrentContextShouldBeTrueWhenEnvironmentVariableIsSet()
        {
            // Arrange
            var buildServer = new GitHubActions(environment, log);

            // Act
            var result = buildServer.CanApplyToCurrentContext();

            // Assert
            result.ShouldBeTrue();
        }
Ejemplo n.º 5
0
        public void SkipEmptySetParameterMessage()
        {
            // Arrange
            var buildServer = new GitHubActions(environment, log);

            // Act
            var result = buildServer.GenerateSetParameterMessage("Hello", string.Empty);

            // Assert
            result.ShouldBeEquivalentTo(new string[0]);
        }
Ejemplo n.º 6
0
        public void CanApplyToCurrentContextShouldBeFalseWhenEnvironmentVariableIsNotSet()
        {
            // Arrange
            environment.SetEnvironmentVariable(GitHubActions.EnvironmentVariableName, "");
            var buildServer = new GitHubActions(environment, log);

            // Act
            var result = buildServer.CanApplyToCurrentContext();

            // Assert
            result.ShouldBeFalse();
        }
Ejemplo n.º 7
0
        public void GetEmptyGenerateSetVersionMessage()
        {
            // Arrange
            var buildServer = new GitHubActions(environment, log);
            var vars        = new TestableVersionVariables("1.0.0");

            // Act
            var message = buildServer.GenerateSetVersionMessage(vars);

            // Assert
            message.ShouldBeEmpty();
        }
Ejemplo n.º 8
0
        public void GetCurrentBranchShouldNotMatchTag()
        {
            // Arrange
            environment.SetEnvironmentVariable("GITHUB_REF", $"refs/tags/v1.0.0");

            var buildServer = new GitHubActions(environment, log);

            // Act
            var result = buildServer.GetCurrentBranch(false);

            // Assert
            result.ShouldBeNull();
        }
Ejemplo n.º 9
0
        public void GetSetParameterMessage(string key, string value, string expectedResult)
        {
            // Arrange
            var buildServer = new GitHubActions(environment, log);

            // Assert
            environment.GetEnvironmentVariable("GitVersion_Something").ShouldBeNullOrWhiteSpace();

            // Act
            var result = buildServer.GenerateSetParameterMessage(key, value);

            // Assert
            result.ShouldContain(s => true, 1);
            result.ShouldBeEquivalentTo(new[] { expectedResult });
        }
Ejemplo n.º 10
0
        public void GetCurrentBranchShouldGetBranchIfSet()
        {
            // Arrange
            const string expected = "actionsBranch";

            environment.SetEnvironmentVariable("GITHUB_REF", $"refs/heads/{expected}");

            var buildServer = new GitHubActions(environment, log);

            // Act
            var result = buildServer.GetCurrentBranch(false);

            // Assert
            result.ShouldBe(expected);
        }