|
| 1 | +namespace GitHubFlowVersion.AcceptanceTests |
| 2 | +{ |
| 3 | + using GitVersion; |
| 4 | + using Shouldly; |
| 5 | + using Helpers; |
| 6 | + using Xunit; |
| 7 | + |
| 8 | + public class MasterTests |
| 9 | + { |
| 10 | + [Fact] |
| 11 | + public void GivenARepositoryWithCommitsButNoTags_VersionShouldBe_0_1() |
| 12 | + { |
| 13 | + using (var fixture = new RepositoryFixture()) |
| 14 | + { |
| 15 | + // Given |
| 16 | + fixture.Repository.MakeACommit(); |
| 17 | + fixture.Repository.MakeACommit(); |
| 18 | + fixture.Repository.MakeACommit(); |
| 19 | + |
| 20 | + // When |
| 21 | + var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath); |
| 22 | + |
| 23 | + result.ExitCode.ShouldBe(0); |
| 24 | + result.Output[VariableProvider.FullSemVer].ShouldBe("0.1.0+2"); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + [Fact] |
| 29 | + public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile() |
| 30 | + { |
| 31 | + using (var fixture = new RepositoryFixture()) |
| 32 | + { |
| 33 | + const string ExpectedNextVersion = "1.0.0"; |
| 34 | + fixture.Repository.MakeACommit(); |
| 35 | + fixture.Repository.MakeACommit(); |
| 36 | + fixture.Repository.MakeACommit(); |
| 37 | + fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion); |
| 38 | + |
| 39 | + var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath); |
| 40 | + |
| 41 | + result.ExitCode.ShouldBe(0); |
| 42 | + result.Output[VariableProvider.FullSemVer].ShouldBe("1.0.0+2"); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + [Fact] |
| 47 | + public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile() |
| 48 | + { |
| 49 | + using (var fixture = new RepositoryFixture()) |
| 50 | + { |
| 51 | + const string ExpectedNextVersion = "1.1.0"; |
| 52 | + const string TaggedVersion = "1.0.3"; |
| 53 | + fixture.Repository.MakeATaggedCommit(TaggedVersion); |
| 54 | + fixture.Repository.MakeCommits(5); |
| 55 | + fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion); |
| 56 | + |
| 57 | + var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath); |
| 58 | + |
| 59 | + result.ExitCode.ShouldBe(0); |
| 60 | + result.Output[VariableProvider.FullSemVer].ShouldBe("1.1.0+5"); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + [Fact] |
| 65 | + public void GivenARepositoryWithTagAndNoNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch() |
| 66 | + { |
| 67 | + using (var fixture = new RepositoryFixture()) |
| 68 | + { |
| 69 | + const string TaggedVersion = "1.0.3"; |
| 70 | + fixture.Repository.MakeATaggedCommit(TaggedVersion); |
| 71 | + fixture.Repository.MakeCommits(5); |
| 72 | + |
| 73 | + var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath); |
| 74 | + |
| 75 | + result.ExitCode.ShouldBe(0); |
| 76 | + result.Output[VariableProvider.FullSemVer].ShouldBe("1.0.4+5"); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + [Fact] |
| 81 | + public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch() |
| 82 | + { |
| 83 | + using (var fixture = new RepositoryFixture()) |
| 84 | + { |
| 85 | + const string NextVersionTxt = "1.0.0"; |
| 86 | + const string TaggedVersion = "1.1.0"; |
| 87 | + fixture.Repository.MakeATaggedCommit(TaggedVersion); |
| 88 | + fixture.Repository.MakeCommits(5); |
| 89 | + fixture.Repository.AddNextVersionTxtFile(NextVersionTxt); |
| 90 | + |
| 91 | + var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath); |
| 92 | + |
| 93 | + result.ExitCode.ShouldBe(0); |
| 94 | + result.Output[VariableProvider.FullSemVer].ShouldBe("1.1.1+5"); |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments