mirror of
https://github.com/sony/sonyflake.git
synced 2025-12-23 05:05:14 +00:00
Make testing simple (#20)
* Make testing simpler * Remove testing deps * Simplemize tests
This commit is contained in:
4
go.mod
4
go.mod
@@ -1,5 +1,3 @@
|
||||
module github.com/sony/sonyflake
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/deckarep/golang-set v1.7.1
|
||||
go 1.13
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1,2 +0,0 @@
|
||||
github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=
|
||||
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/deckarep/golang-set"
|
||||
)
|
||||
|
||||
var sf *Sonyflake
|
||||
@@ -139,16 +137,15 @@ func TestSonyflakeInParallel(t *testing.T) {
|
||||
go generate()
|
||||
}
|
||||
|
||||
set := mapset.NewSet()
|
||||
set := make(map[uint64]struct{})
|
||||
for i := 0; i < numID*numGenerator; i++ {
|
||||
id := <-consumer
|
||||
if set.Contains(id) {
|
||||
if _, ok := set[id]; ok {
|
||||
t.Fatal("duplicated id")
|
||||
} else {
|
||||
set.Add(id)
|
||||
}
|
||||
set[id] = struct{}{}
|
||||
}
|
||||
fmt.Println("number of id:", set.Cardinality())
|
||||
fmt.Println("number of id:", len(set))
|
||||
}
|
||||
|
||||
func TestNilSonyflake(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user