Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
kekyo committed Jul 2, 2023
1 parent e4af1ea commit ab3fc17
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 102 deletions.
32 changes: 32 additions & 0 deletions CenterCLR.RelaxVersioner.Core.Tests/AnalyzerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// RelaxVersioner - Git tag/branch based, full-automatic version information inserter.
// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
////////////////////////////////////////////////////////////////////////////////////////

using GitReader;
using GitReader.Structures;
using NUnit.Framework;
using System.IO;
using System.Threading.Tasks;

namespace RelaxVersioner;

public sealed class AnalyzerTests
{
[TestCase("NothingAnyTags1", "0.0.4")]
[TestCase("TagInPrimary", "0.10.1")]
[TestCase("TagInSecondary", "0.20.1")]
public async Task LookupVersionLabel(string repositoryName, string expectedString)
{
using var repository = await Repository.Factory.OpenStructureAsync(
Path.Combine(TestsSetUp.BasePath, repositoryName));

var actual = await Analyzer.LookupVersionLabelAsync(repository.Head!, default);

Assert.AreEqual(expectedString, actual.ToString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<TargetFrameworks>net48;net5.0;net6.0;net7.0</TargetFrameworks>
<NoWarn>$(NoWarn);NU5104</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Verify.NUnit" Version="19.13.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CenterCLR.RelaxVersioner.Core\CenterCLR.RelaxVersioner.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="artifacts\" />
</ItemGroup>

<ItemGroup>
<None Update="artifacts\*.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
46 changes: 46 additions & 0 deletions CenterCLR.RelaxVersioner.Core.Tests/TestsSetUp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// RelaxVersioner - Git tag/branch based, full-automatic version information inserter.
// Copyright (c) Kouji Matsui (@kozy_kekyo, @kekyo@mastodon.cloud)
//
// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.IO;
using System.IO.Compression;
using VerifyTests;

namespace RelaxVersioner;

public sealed class TestsSetUp
{
public static readonly string BasePath =
Path.Combine("tests", $"{DateTime.Now:yyyyMMdd_HHmmss}");

static TestsSetUp()
{
VerifierSettings.DontScrubDateTimes();

if (!Directory.Exists(BasePath))
{
foreach (var path in Directory.EnumerateFiles(
"artifacts", "*.zip", SearchOption.AllDirectories))
{
var fileName = Path.GetFileNameWithoutExtension(path);
var targetBasePath = Path.Combine(BasePath, fileName);

try
{
Directory.CreateDirectory(targetBasePath);
}
catch
{
}

ZipFile.ExtractToDirectory(path, targetBasePath);
}
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ab3fc17

Please sign in to comment.