Skip to content

Commit b192e17

Browse files
committed
Added a failing testcase to set up the expectations
for translating the pre-release labels in Git tags to weights.
1 parent 1cd63f5 commit b192e17

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using GitTools.Testing;
4+
using GitVersion.Configuration;
5+
using GitVersion.Extensions;
6+
using GitVersion.Model.Configuration;
7+
using GitVersion.VersionCalculation;
8+
using GitVersionCore.Tests.Helpers;
9+
using LibGit2Sharp;
10+
using NUnit.Framework;
11+
using Shouldly;
12+
13+
namespace GitVersionCore.Tests.VersionCalculation.Strategies
14+
{
15+
[TestFixture]
16+
public class TaggedCommitVersionStrategyTests : TestBase
17+
{
18+
[TestCase]
19+
public void TagWithPreReleaseLabelShouldBeTranslatedToPreReleaseWeight()
20+
{
21+
/*todo: Extend the configuration to specify the regex & pre-release weights
22+
for the tags.
23+
*/
24+
25+
using var fixture = new EmptyRepositoryFixture();
26+
fixture.Repository.MakeACommit();
27+
fixture.BranchTo("develop");
28+
fixture.Repository.MakeATaggedCommit("v1.0.0-alpha");
29+
30+
var strategy = GetVersionStrategy(fixture.Repository, "develop");
31+
var baseVersion = strategy.GetVersions().Single();
32+
33+
baseVersion.SemanticVersion.ToString().ShouldBe("1.0.0-1000");
34+
}
35+
36+
private static IVersionStrategy GetVersionStrategy(
37+
IRepository repository, string branch, Config config = null)
38+
{
39+
var sp = BuildServiceProvider(repository, branch, config);
40+
return sp.GetServiceForType<IVersionStrategy, TaggedCommitVersionStrategy>();
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)