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:
Yoshiyuki MineoandYusuf Syaifudin authored and GitHub committed 2022-08-17 14:33:52 +09:00
1 parent 3719d006ac
commit cc94b60628
1 file changed
+4 -1
+4 -1
View File
@@ -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()