8000 Enforce Configuration.BuildSignature test coverage · github/libgit2sharp@1e79a42 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 1e79a42

Browse files
committed
Enforce Configuration.BuildSignature test coverage
1 parent f211cbc commit 1e79a42

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -538,27 +538,6 @@ public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull()
538538
}
539539
}
540540

541-
[Theory]
542-
[InlineData(null, "x@example.com")]
543-
[InlineData("", "x@example.com")]
544-
[InlineData("X", null)]
545-
[InlineData("X", "")]
546-
public void CommitWithInvalidSignatureConfigThrows(string name, string email)
547-
{
548-
string repoPath = InitNewRepository();
549-
string configPath = CreateConfigurationWithDummyUser(name, email);
550-
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
551-
552-
using (var repo = new Repository(repoPath, options))
553-
{
554-
Assert.Equal(name, repo.Config.GetValueOrDefault<string>("user.name"));
555-
Assert.Equal(email, repo.Config.GetValueOrDefault<string>("user.email"));
556-
557-
Assert.Throws<LibGit2SharpException>(
558-
() => repo.Commit("Initial egotistic commit", new CommitOptions { AllowEmptyCommit = true }));
559-
}
560-
}
561-
562541
[Fact]
563542
public void CanCommitWithSignatureFromConfig()
564543
{

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,5 +409,27 @@ public void PassingANonExistingLocalConfigurationFileToBuildFromthrowss()
409409
Assert.Throws<FileNotFoundException>(() => Configuration.BuildFrom(
410410
Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())));
411411
}
412+
413+
[Theory]
414+
[InlineData(null, "x@example.com")]
415+
[InlineData("", "x@example.com")]
416+
[InlineData("X", null)]
417+
[InlineData("X", "")]
418+
public void CannotBuildAProperSignatureFromConfigWhenFullIdentityCannotBeFoundInTheConfig(string name, string email)
419+
{
420+
string repoPath = InitNewRepository();
421+
string configPath = CreateConfigurationWithDummyUser(name, email);
422+
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
423+
424+
using (var repo = new Repository(repoPath, options))
425+
{
426+
Assert.Equal(name, repo.Config.GetValueOrDefault<string>("user.name"));
427+
Assert.Equal(email, repo.Config.GetValueOrDefault<string>("user.email"));
428+
429+
Signature signature = repo.Config.BuildSignature(DateTimeOffset.Now);
430+
431+
Assert.Null(signature);
432+
}
433+
}
412434
}
413435
}

0 commit comments

Comments
 (0)
0