aboutsummaryrefslogtreecommitdiffstats
path: root/identity/identity_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-05-01 00:25:45 +0200
committerMichael Muré <batolettre@gmail.com>2020-05-01 00:35:00 +0200
commitfb31f80120457bba76dc336a68ceae2efb7b8579 (patch)
tree13f28e134b7eac8651fed46db4f51863dd8bed27 /identity/identity_test.go
parent0434d9203a4accb8a805ed272b340a3a19d286b4 (diff)
downloadgit-bug-fb31f80120457bba76dc336a68ceae2efb7b8579.tar.gz
identity: actually test the mutator
Diffstat (limited to 'identity/identity_test.go')
-rw-r--r--identity/identity_test.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/identity/identity_test.go b/identity/identity_test.go
index ee6ccdf7..f9091294 100644
--- a/identity/identity_test.go
+++ b/identity/identity_test.go
@@ -79,11 +79,6 @@ func TestIdentityCommitLoad(t *testing.T) {
// add more version
- identity.Mutate(func(orig Mutator) Mutator {
-
- return orig
- })
-
identity.addVersionForTest(&Version{
time: 201,
name: "René Descartes",
@@ -113,6 +108,24 @@ func TestIdentityCommitLoad(t *testing.T) {
assert.Equal(t, identity, loaded)
}
+func TestIdentityMutate(t *testing.T) {
+ identity := NewIdentity("René Descartes", "rene.descartes@example.com")
+
+ assert.Len(t, identity.versions, 1)
+
+ identity.Mutate(func(orig Mutator) Mutator {
+ orig.Email = "rene@descartes.fr"
+ orig.Name = "René"
+ orig.Login = "rene"
+ return orig
+ })
+
+ assert.Len(t, identity.versions, 2)
+ assert.Equal(t, identity.Email(), "rene@descartes.fr")
+ assert.Equal(t, identity.Name(), "René")
+ assert.Equal(t, identity.Login(), "rene")
+}
+
func commitsAreSet(t *testing.T, identity *Identity) {
for _, version := range identity.versions {
assert.NotEmpty(t, version.commitHash)