diff options
author | Michael Muré <batolettre@gmail.com> | 2019-01-20 15:41:27 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-03-01 22:40:22 +0100 |
commit | 14b240af8fef269d2c1d5dde2fff192b656c50f3 (patch) | |
tree | 4f6ea032789d811cd019bbb6c190c99a650084b2 /identity/identity_test.go | |
parent | d10c76469d40f13e27739fd363145e89bf74c3e0 (diff) | |
download | git-bug-14b240af8fef269d2c1d5dde2fff192b656c50f3.tar.gz |
identity: more cleaning and fixes after a code review
Diffstat (limited to 'identity/identity_test.go')
-rw-r--r-- | identity/identity_test.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/identity/identity_test.go b/identity/identity_test.go index 914126be..afb804fc 100644 --- a/identity/identity_test.go +++ b/identity/identity_test.go @@ -8,12 +8,13 @@ import ( "github.com/stretchr/testify/require" ) +// Test the commit and load of an Identity with multiple versions func TestIdentityCommitLoad(t *testing.T) { mockRepo := repository.NewMockRepoForTest() // single version - identity := Identity{ + identity := &Identity{ Versions: []*Version{ { Name: "René Descartes", @@ -30,11 +31,11 @@ func TestIdentityCommitLoad(t *testing.T) { loaded, err := Read(mockRepo, identity.id) assert.Nil(t, err) commitsAreSet(t, loaded) - equivalentIdentity(t, &identity, loaded) + equivalentIdentity(t, identity, loaded) // multiple version - identity = Identity{ + identity = &Identity{ Versions: []*Version{ { Time: 100, @@ -71,7 +72,7 @@ func TestIdentityCommitLoad(t *testing.T) { loaded, err = Read(mockRepo, identity.id) assert.Nil(t, err) commitsAreSet(t, loaded) - equivalentIdentity(t, &identity, loaded) + equivalentIdentity(t, identity, loaded) // add more version @@ -101,7 +102,7 @@ func TestIdentityCommitLoad(t *testing.T) { loaded, err = Read(mockRepo, identity.id) assert.Nil(t, err) commitsAreSet(t, loaded) - equivalentIdentity(t, &identity, loaded) + equivalentIdentity(t, identity, loaded) } func commitsAreSet(t *testing.T, identity *Identity) { @@ -120,6 +121,7 @@ func equivalentIdentity(t *testing.T, expected, actual *Identity) { assert.Equal(t, expected, actual) } +// Test that the correct crypto keys are returned for a given lamport time func TestIdentity_ValidKeysAtTime(t *testing.T) { identity := Identity{ Versions: []*Version{ @@ -176,6 +178,7 @@ func TestIdentity_ValidKeysAtTime(t *testing.T) { assert.Equal(t, identity.ValidKeysAtTime(3000), []Key{{PubKey: "pubkeyE"}}) } +// Test the immutable or mutable metadata search func TestMetadata(t *testing.T) { mockRepo := repository.NewMockRepoForTest() |