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)); }
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); }
public void SetUp() { var sp = ConfigureServices(services => { services.AddSingleton <GitHubActions>(); }); environment = sp.GetService <IEnvironment>(); buildServer = sp.GetService <GitHubActions>(); environment.SetEnvironmentVariable(GitHubActions.EnvironmentVariableName, "true"); }
public void CanApplyToCurrentContextShouldBeTrueWhenEnvironmentVariableIsSet() { // Arrange var buildServer = new GitHubActions(environment, log); // Act var result = buildServer.CanApplyToCurrentContext(); // Assert result.ShouldBeTrue(); }
public void SkipEmptySetParameterMessage() { // Arrange var buildServer = new GitHubActions(environment, log); // Act var result = buildServer.GenerateSetParameterMessage("Hello", string.Empty); // Assert result.ShouldBeEquivalentTo(new string[0]); }
public void CanApplyToCurrentContextShouldBeFalseWhenEnvironmentVariableIsNotSet() { // Arrange environment.SetEnvironmentVariable(GitHubActions.EnvironmentVariableName, ""); var buildServer = new GitHubActions(environment, log); // Act var result = buildServer.CanApplyToCurrentContext(); // Assert result.ShouldBeFalse(); }
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(); }
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(); }
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 }); }
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); }