mirror of
https://github.com/sony/sonyflake.git
synced 2026-01-04 18:43:56 +00:00
Check time order explicitly (#37)
* Add sortable test (#11) * add TestSortableID to make sure that generated ID(s) can be sorted like you are using increment id database * add TestSortableID to make sure that generated ID(s) can be sorted like you are using increment id database Co-authored-by: Yoshiyuki Mineo <Yoshiyuki.Mineo@jp.sony.com> * gofmt * Check time order explicitly Co-authored-by: Yusuf Syaifudin <yusuf.syaifudin@gmail.com>
This commit is contained in:
@@ -76,9 +76,12 @@ func TestSonyflakeFor10Sec(t *testing.T) {
|
||||
parts := Decompose(id)
|
||||
numID++
|
||||
|
||||
if id <= lastID {
|
||||
if id == lastID {
|
||||
t.Fatal("duplicated id")
|
||||
}
|
||||
if id < lastID {
|
||||
t.Fatal("must increase with time")
|
||||
}
|
||||
lastID = id
|
||||
|
||||
current = currentTime()
|
||||
|
||||
Reference in New Issue
Block a user