From 719303226096c905e602cb620dfdfbcf8fe106ad Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 19 Feb 2019 01:44:21 +0100 Subject: identity: fix tests --- identity/identity.go | 2 +- identity/version.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'identity') diff --git a/identity/identity.go b/identity/identity.go index b9d40967..809719e6 100644 --- a/identity/identity.go +++ b/identity/identity.go @@ -416,7 +416,7 @@ func (i *Identity) Validate() error { return err } - if v.time < lastTime { + if v.commitHash != "" && v.time < lastTime { return fmt.Errorf("non-chronological version (%d --> %d)", lastTime, v.time) } diff --git a/identity/version.go b/identity/version.go index 6ffffd99..1259ae9c 100644 --- a/identity/version.go +++ b/identity/version.go @@ -100,9 +100,13 @@ func (v *Version) UnmarshalJSON(data []byte) error { } func (v *Version) Validate() error { - if v.unixTime == 0 { + // time must be set after a commit + if v.commitHash != "" && v.unixTime == 0 { return fmt.Errorf("unix time not set") } + if v.commitHash != "" && v.time == 0 { + return fmt.Errorf("lamport time not set") + } if text.Empty(v.name) && text.Empty(v.login) { return fmt.Errorf("either name or login should be set") -- cgit