mirror of
https://github.com/sony/sonyflake.git
synced 2026-11-28 00:46:33 +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:
1 parent
3719d006ac
commit
cc94b60628
1 file changed
+4
-1
+4
-1
@@ -76,9 +76,12 @@ func TestSonyflakeFor10Sec(t *testing.T) {
|
|||||||
parts := Decompose(id)
|
parts := Decompose(id)
|
||||||
numID++
|
numID++
|
||||||
|
|
||||||
if id <= lastID {
|
if id == lastID {
|
||||||
t.Fatal("duplicated id")
|
t.Fatal("duplicated id")
|
||||||
}
|
}
|
||||||
|
if id < lastID {
|
||||||
|
t.Fatal("must increase with time")
|
||||||
|
}
|
||||||
lastID = id
|
lastID = id
|
||||||
|
|
||||||
current = currentTime()
|
current = currentTime()
|
||||||
|
|||||||
Reference in new issue
Block a user