-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test for the output with build server and json when running in …
…build server
- Loading branch information
Showing
4 changed files
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections.Generic; | ||
using GitTools.Testing; | ||
using GitVersion.BuildServers; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace GitVersionExe.Tests | ||
{ | ||
public class JsonOutputOnBuildServerTest | ||
{ | ||
[Test] | ||
public void BeingOnBuildServerDoesntOverrideOutputJson() | ||
{ | ||
using var fixture = new RemoteRepositoryFixture(); | ||
fixture.Repository.MakeATaggedCommit("1.2.3"); | ||
fixture.Repository.MakeACommit(); | ||
|
||
var env = new KeyValuePair<string, string>(TeamCity.EnvironmentVariableName, "8.0.0"); | ||
|
||
var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: " /output json", environments: env); | ||
|
||
result.ExitCode.ShouldBe(0); | ||
result.Output.ShouldStartWith("{"); | ||
result.Output.TrimEnd().ShouldEndWith("}"); | ||
} | ||
|
||
[Test] | ||
public void BeingOnBuildServerWithOutputJsonDoesNotFail() | ||
{ | ||
using var fixture = new RemoteRepositoryFixture(); | ||
fixture.Repository.MakeATaggedCommit("1.2.3"); | ||
fixture.Repository.MakeACommit(); | ||
|
||
var env = new KeyValuePair<string, string>(TeamCity.EnvironmentVariableName, "8.0.0"); | ||
|
||
var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: " /output json /output buildserver", environments: env); | ||
|
||
result.ExitCode.ShouldBe(0); | ||
const string version = "0.1.0+4"; | ||
result.Output.ShouldContain($"##teamcity[buildNumber '{version}']"); | ||
result.OutputVariables.ShouldNotBeNull(); | ||
result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters