Skip to content

Commit

Permalink
Favor Identity usage over Signature in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltoken committed Aug 18, 2015
1 parent d114368 commit f211cbc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public void CommitWithInvalidSignatureConfigThrows(string name, string email)
public void CanCommitWithSignatureFromConfig()
{
string repoPath = InitNewRepository();
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

using (var repo = new Repository(repoPath, options))
Expand All @@ -586,7 +586,7 @@ public void CanCommitWithSignatureFromConfig()
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
AssertBlobContent(commit[relativeFilepath], "nulltoken\n");

AssertCommitSignaturesAre(commit, Constants.Signature);
AssertCommitIdentitiesAre(commit, Constants.Identity);
}
}

Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/ConfigurationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void CanReadStringValue()
[Fact]
public void CanEnumerateGlobalConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

var path = SandboxStandardTestRepoGitDir();
Expand Down Expand Up @@ -200,7 +200,7 @@ public void CanFindInLocalConfig()
[Fact]
public void CanFindInGlobalConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };

var path = SandboxStandardTestRepoGitDir();
Expand Down Expand Up @@ -387,7 +387,7 @@ public void CanAccessConfigurationWithoutARepository(Func<string, string> localC
{
var path = SandboxStandardTestRepoGitDir();

string globalConfigPath = CreateConfigurationWithDummyUser(Constants.Signature);
string globalConfigPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = globalConfigPath };

using (var repo = new Repository(path, options))
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/FilterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void CanFilterLargeFiles()
string attributesPath = Path.Combine(Directory.GetParent(repoPath).Parent.FullName, ".gitattributes");
FileInfo attributesFile = new FileInfo(attributesPath);

string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };

using (Repository repo = new Repository(repoPath, repositoryOptions))
Expand Down Expand Up @@ -377,7 +377,7 @@ private static FileInfo StageNewFile(IRepository repo, string contents = "null")

private Repository CreateTestRepository(string path)
{
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
var repository = new Repository(path, repositoryOptions);
CreateAttributesFile(repository, "* filter=test");
Expand Down
10 changes: 5 additions & 5 deletions LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void SmugdeIsNotCalledForFileWhichDoesNotMatchAnAttributeEntry()

string repoPath = InitNewRepository();
string fileName = Guid.NewGuid() + ".rot13";
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, repositoryOptions))
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public void CorrectlyEncodesAndDecodesInput()

string repoPath = InitNewRepository();
string fileName = Guid.NewGuid() + ".rot13";
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, repositoryOptions))
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public void WhenStagedFileDoesNotMatchPathSpecFileIsNotFiltered(string pathSpec,
string repoPath = InitNewRepository();
string fileName = Guid.NewGuid() + fileExtension;

string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, repositoryOptions))
{
Expand Down Expand Up @@ -141,7 +141,7 @@ public void CleanIsCalledIfAttributeEntryMatches(string filterAttribute, string
string repoPath = InitNewRepository();
string fileName = Guid.NewGuid() + ".txt";

string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, repositoryOptions))
{
Expand Down Expand Up @@ -172,7 +172,7 @@ public void SmudgeIsCalledIfAttributeEntryMatches(string filterAttribute, string
string repoPath = InitNewRepository();
string fileName = Guid.NewGuid() + ".txt";

string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath };
using (var repo = new Repository(repoPath, repositoryOptions))
{
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/NoteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void CreatingANoteWhichAlreadyExistsOverwritesThePreviousNote()
[Fact]
public void CanAddANoteWithSignatureFromConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
var options = new RepositoryOptions { GlobalConfigurationLocation = configPath };
string path = SandboxBareTestRepo();

Expand All @@ -183,7 +183,7 @@ public void CanAddANoteWithSignatureFromConfig()
Assert.Equal("I'm batman!\n", newNote.Message);
Assert.Equal("batmobile", newNote.Namespace);

AssertCommitSignaturesAre(repo.Lookup<Commit>("refs/notes/batmobile"), Constants.Signature);
AssertCommitIdentitiesAre(repo.Lookup<Commit>("refs/notes/batmobile"), Constants.Identity);
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public void RemovingANonExistingNoteDoesntThrow()
[Fact]
public void CanRemoveANoteWithSignatureFromConfig()
{
string configPath = CreateConfigurationWithDummyUser(Constants.Signature);
string configPath = CreateConfigurationWithDummyUser(Constants.Identity);
RepositoryOptions options = new RepositoryOptions() { GlobalConfigurationLocation = configPath };
string path = SandboxBareTestRepo();

Expand All @@ -280,7 +280,7 @@ public void CanRemoveANoteWithSignatureFromConfig()

Assert.Empty(notes);

AssertCommitSignaturesAre(repo.Lookup<Commit>("refs/notes/" + repo.Notes.DefaultNamespace), Constants.Signature);
AssertCommitIdentitiesAre(repo.Lookup<Commit>("refs/notes/" + repo.Notes.DefaultNamespace), Constants.Identity);
}
}

Expand Down
18 changes: 9 additions & 9 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ private static RepositoryOptions BuildFakeRepositoryOptions(SelfCleaningDirector
/// Creates a configuration file with user.name and user.email set to signature
/// </summary>
/// <remarks>The configuration file will be removed automatically when the tests are finished</remarks>
/// <param name="signature">The signature to use for user.name and user.email</param>
/// <param name="identity">The identity to use for user.name and user.email</param>
/// <returns>The path to the configuration file</returns>
protected string CreateConfigurationWithDummyUser(Signature signature)
protected string CreateConfigurationWithDummyUser(Identity identity)
{
return CreateConfigurationWithDummyUser(signature.Name, signature.Email);
return CreateConfigurationWithDummyUser(identity.Name, identity.Email);
}

protected string CreateConfigurationWithDummyUser(string name, string email)
Expand Down Expand Up @@ -361,13 +361,13 @@ protected string CreateConfigurationWithDummyUser(string name, string email)
/// Asserts that the commit has been authored and committed by the specified signature
/// </summary>
/// <param name="commit">The commit</param>
/// <param name="signature">The signature to compare author and commiter to</param>
protected void AssertCommitSignaturesAre(Commit commit, Signature signature)
/// <param name="identity">The identity to compare author and commiter to</param>
protected void AssertCommitIdentitiesAre(Commit commit, Identity identity)
{
Assert.Equal(signature.Name, commit.Author.Name);
Assert.Equal(signature.Email, commit.Author.Email);
Assert.Equal(signature.Name, commit.Committer.Name);
Assert.Equal(signature.Email, commit.Committer.Email);
Assert.Equal(identity.Name, commit.Author.Name);
Assert.Equal(identity.Email, commit.Author.Email);
Assert.Equal(identity.Name, commit.Committer.Name);
Assert.Equal(identity.Email, commit.Committer.Email);
}

protected static string Touch(string parent, string file, string content = null, Encoding encoding = null)
Expand Down

0 comments on commit f211cbc

Please sign in to comment.