35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
using ClaudeDo.Data.Git;
|
|
using ClaudeDo.Worker.Git;
|
|
using ClaudeDo.Worker.Tests.Infrastructure;
|
|
|
|
namespace ClaudeDo.Worker.Tests.Git;
|
|
|
|
public sealed class CompanyRepoTests : IDisposable
|
|
{
|
|
private readonly GitRepoFixture _repo = new();
|
|
public void Dispose() => _repo.Dispose();
|
|
|
|
[Theory]
|
|
[InlineData("https://srv.local/Coll/Proj/_git/Repo", "/_git/", true)]
|
|
[InlineData("https://mika@srv.local/tfs/Coll/Proj/_git/Mein%20Repo.git", "/_git/", true)]
|
|
[InlineData("ssh://git@git.kuns.dev:22222/kuns/ClaudeDo.git", "/_git/", false)]
|
|
[InlineData(null, "/_git/", false)]
|
|
[InlineData("https://srv.local/Coll/Proj/_git/Repo", "", false)]
|
|
[InlineData("https://GITHUB.com/acme/repo.git", "github.com/acme", true)]
|
|
public void Matches(string? url, string pattern, bool expected)
|
|
=> Assert.Equal(expected, CompanyRepo.Matches(url, pattern));
|
|
|
|
[Fact]
|
|
public async Task IsCompanyAsync_reads_origin()
|
|
{
|
|
if (!GitRepoFixture.IsGitAvailable()) return;
|
|
var git = new GitService();
|
|
Assert.False(await CompanyRepo.IsCompanyAsync(git, _repo.RepoDir, "/_git/", CancellationToken.None));
|
|
|
|
GitRepoFixture.RunGit(_repo.RepoDir, "remote", "add", "origin", "https://srv.local/Coll/Proj/_git/Repo");
|
|
|
|
Assert.True(await CompanyRepo.IsCompanyAsync(git, _repo.RepoDir, "/_git/", CancellationToken.None));
|
|
Assert.Equal("https://srv.local/Coll/Proj/_git/Repo", await git.GetRemoteUrlAsync(_repo.RepoDir));
|
|
}
|
|
}
|