Skip to content

Fixing tests #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<Compile Include="GitDirFinderTests.cs" />
<Compile Include="Fixtures\BaseGitFlowRepositoryFixture.cs" />
<Compile Include="GitVersionContextTests.cs" />
<Compile Include="IntegrationTests\PullRequestScenarios.cs" />
<Compile Include="IntegrationTests\RemoteRepositoryTests.cs" />
<Compile Include="IntegrationTests\GitFlow\DevelopScenarios.cs" />
<Compile Include="IntegrationTests\GitFlow\GitFlowFeatureBranchTests.cs" />
Expand Down
59 changes: 30 additions & 29 deletions GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,78 @@ public void WhenDevelopBranchedFromTaggedCommitOnMasterVersionDoesNotChange()
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
// TODO Should actually be 1.0.0+0
fixture.AssertFullSemver("1.1.0-unstable.0+0");
fixture.AssertFullSemver("1.0.0+0");
}
}

[Test]
public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
public void CanChangeDevelopTagViaConfig()
{
using (var fixture = new EmptyRepositoryFixture(new Config()))
var config = new Config();
config.Branches["develop"].Tag = "alpha";
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.1.0-unstable.1+1");
fixture.AssertFullSemver("1.1.0-alpha.1+1");
}
}

[Test]
public void MergingReleaseBranchBackIntoDevelopWithoutMergingToMaster_DoesNotBumpDevelopVersion()
public void CanClearDevelopTagViaConfig()
{
using (var fixture = new EmptyRepositoryFixture(new Config()))
var config = new Config();
config.Branches["develop"].Tag = "";
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeACommit();
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
fixture.AssertFullSemver("2.0.0-beta.1+0");
fixture.Repository.Checkout("develop");
fixture.AssertFullSemver("1.1.0-unstable.1+1");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());
fixture.AssertFullSemver("1.1.0-unstable.1+1");
fixture.AssertFullSemver("1.1.0+1");
}
}

[Test]
public void CanChangeDevelopTagViaConfig()
public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
{
var config = new Config();
config.Branches["develop"].Tag = "alpha";
using (var fixture = new EmptyRepositoryFixture(config))
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0-alpha.0+0");
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.1.0-unstable.1+1");
}
}

[Test]
public void CanHandleContinuousDelivery()
public void MergingReleaseBranchBackIntoDevelopWithoutMergingToMaster_DoesNotBumpDevelopVersion()
{
var config = new Config();
config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDelivery;
using (var fixture = new EmptyRepositoryFixture(config))
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.Repository.MakeATaggedCommit("1.1.0-alpha7");
fixture.AssertFullSemver("1.1.0-alpha.7+1");
fixture.Repository.MakeACommit();
fixture.Repository.CreateBranch("release-2.0.0").Checkout();
fixture.AssertFullSemver("2.0.0-beta.1+0");
fixture.Repository.Checkout("develop");
fixture.AssertFullSemver("1.1.0-unstable.1+1");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());
fixture.AssertFullSemver("1.1.0-unstable.1+1");
}
}

[Test]
public void CanClearDevelopTagViaConfig()
public void CanHandleContinuousDelivery()
{
var config = new Config();
config.Branches["develop"].Tag = "";
config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDelivery;
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0+0");
fixture.Repository.MakeATaggedCommit("1.1.0-alpha7");
fixture.AssertFullSemver("1.1.0-alpha.7+0");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ShouldNotUseNumberInFeatureBranchAsPreReleaseNumber()
fixture.Repository.Checkout("feature/JIRA-123");
fixture.Repository.MakeCommits(5);

fixture.AssertFullSemver("1.1.0-JIRA-123+5");
fixture.AssertFullSemver("1.1.0-JIRA-123.1+5");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this new behaviour is correct. the .1 is the same as we put on -beta, -unstable etc.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public void PatchLatestReleaseExample()
// create hotfix
fixture.Repository.CreateBranch("hotfix-1.2.1").Checkout();

fixture.AssertFullSemver("1.2.1-beta.1+1");
fixture.AssertFullSemver("1.2.1-beta.1+0");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example of new commit counting. We have not commited to the new branch, so why was it 1?

fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.1-beta.1+2");
fixture.AssertFullSemver("1.2.1-beta.1+1");
fixture.Repository.ApplyTag("1.2.1-beta.1");
fixture.AssertFullSemver("1.2.1-beta.1+2");
fixture.AssertFullSemver("1.2.1-beta.1+0");
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.1-beta.2+3");
fixture.AssertFullSemver("1.2.1-beta.2+1");

// Merge hotfix branch to master
fixture.Repository.Checkout("master");
Expand Down
41 changes: 14 additions & 27 deletions GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public void CanTakeVersionFromReleaseBranch()
fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");

fixture.AssertFullSemver("2.0.0-beta.1+5");
fixture.AssertFullSemver("2.0.0-beta.1+0");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, haven't commited to the release branch yet, so commit count is 0

fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0-beta.1+2");
}
}

Expand All @@ -33,26 +35,9 @@ public void CanTakeVersionFromReleaseBranchWithTagOverriden()
fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");

fixture.AssertFullSemver("2.0.0-rc.1+5");
}
}

[Test]
public void CanHandleContinuousDeployment()
{
var config = new Config
{
VersioningMode = VersioningMode.ContinuousDeployment
};
using (var fixture = new EmptyRepositoryFixture(config))
{
fixture.Repository.MakeATaggedCommit("1.0.3");
fixture.Repository.CreateBranch("develop");
fixture.Repository.MakeCommits(5);
fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");

fixture.AssertFullSemver("2.0.0-beta.5+5");
fixture.AssertFullSemver("2.0.0-rc.1+0");
fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0-rc.1+2");
}
}

Expand All @@ -67,7 +52,9 @@ public void CanHandleReleaseBranchWithStability()
fixture.Repository.CreateBranch("release-2.0.0-Final");
fixture.Repository.Checkout("release-2.0.0-Final");

fixture.AssertFullSemver("2.0.0-beta.1+5");
fixture.AssertFullSemver("2.0.0-beta.1+0");
fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0-beta.1+2");
}
}

Expand All @@ -85,13 +72,13 @@ public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt()
fixture.Repository.Checkout("master");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

// TODO For GitHubFlow this is 2.0.0+6, why is it different
fixture.AssertFullSemver("2.0.0");
fixture.AssertFullSemver("2.0.0+0");
fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0+2");
}
}

// TODO This test fails for GitFlow, it needs to be fixed (although in reality a support branch should be used)
[Test, Ignore]
[Test]
public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt()
{
using (var fixture = new EmptyRepositoryFixture(new Config()))
Expand All @@ -116,7 +103,7 @@ public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt()
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow());

fixture.AssertFullSemver("2.0.0+11");
fixture.AssertFullSemver("2.0.0-unstable.1+5");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReac
fixture.Repository.MakeATaggedCommit("1.0.0.0");
fixture.Repository.MakeCommits(2);
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.1.0-unstable.0+0");
fixture.AssertFullSemver("1.1.0-unstable.1+2");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void MinorReleaseExample()

// Branch to develop
fixture.Repository.CreateBranch("develop").Checkout();
fixture.AssertFullSemver("1.3.0-unstable.0+0");
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.3.0-unstable.1+1");

// Open Pull Request
fixture.Repository.CreateBranch("pull/2/merge").Checkout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void ShouldNotUseNumberInFeatureBranchAsPreReleaseNumber()
fixture.Repository.Checkout("feature/JIRA-123");
fixture.Repository.MakeCommits(5);

fixture.AssertFullSemver("1.0.1-JIRA-123+5");
fixture.AssertFullSemver("1.0.1-JIRA-123.1+5");
}
}

Expand All @@ -29,7 +29,7 @@ public void TestFeatureBranch()
fixture.Repository.Checkout("feature-test");
fixture.Repository.MakeCommits(5);

fixture.AssertFullSemver("1.0.1-feature-test+5");
fixture.AssertFullSemver("1.0.1-test.1+5");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public void SupportIsCalculatedCorrectly()
// Create 1.2.0 release
fixture.Repository.Checkout("support/1.0.0");
fixture.Repository.MergeNoFF("release/1.2.0");
fixture.AssertFullSemver("1.2.0+2");
fixture.AssertFullSemver("1.2.0+0");
fixture.Repository.ApplyTag("1.2.0");

// Create 1.2.1 hotfix
fixture.Repository.CreateBranch("hotfix/1.2.1").Checkout();
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.2.1+1");
fixture.AssertFullSemver("1.2.1-beta.1+1");
fixture.Repository.Checkout("support/1.0.0");
fixture.Repository.MergeNoFF("hotfix/1.2.1");
fixture.AssertFullSemver("1.2.1+2");
fixture.AssertFullSemver("1.2.1+0");
}
}

Expand All @@ -69,7 +69,7 @@ public void WhenSupportIsBranchedAndTaggedFromAnotherSupportEnsureNewMinorIsUsed
fixture.Repository.MakeACommit();
fixture.Repository.MakeACommit();

fixture.AssertFullSemver("1.3.1+2");
fixture.AssertFullSemver("1.3.1+0");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public void CanTakeVersionFromReleaseBranch()
fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");

fixture.AssertFullSemver("2.0.0-beta.1+5");
fixture.AssertFullSemver("2.0.0-beta.1+0");
fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0-beta.1+2");
}
}

Expand All @@ -31,7 +33,9 @@ public void CanTakeVersionFromReleaseBranchWithTagOverriden()
fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");

fixture.AssertFullSemver("2.0.0-rc.1+5");
fixture.AssertFullSemver("2.0.0-rc.1+0");
fixture.Repository.MakeCommits(2);
fixture.AssertFullSemver("2.0.0-rc.1+2");
}
}

Expand All @@ -48,7 +52,7 @@ public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt()
fixture.Repository.Checkout("master");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

fixture.AssertFullSemver("2.0.0+6");
fixture.AssertFullSemver("2.0.0+0");
}
}
[Test]
Expand All @@ -71,7 +75,7 @@ public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt()
fixture.Repository.Checkout("master");
fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow());

fixture.AssertFullSemver("2.0.0+11");
fixture.AssertFullSemver("2.0.0+5");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is because we are not as smart with commit counting. It is counting commits along the branch, not including the commits which were merged in. Is this an issue?

}
}

Expand Down
Loading