From 848d664ceea4c980874f2135c85c42409c530b1f Mon Sep 17 00:00:00 2001 From: Osamu TONOMORI Date: Thu, 27 Aug 2020 10:17:19 +0900 Subject: [PATCH] Make testing simple (#20) * Make testing simpler * Remove testing deps * Simplemize tests --- go.mod | 4 +--- go.sum | 2 -- sonyflake_test.go | 11 ++++------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 99ab181..32514e8 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 898e5f9..e69de29 100644 --- a/go.sum +++ b/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= diff --git a/sonyflake_test.go b/sonyflake_test.go index 4edcb0f..a52476f 100644 --- a/sonyflake_test.go +++ b/sonyflake_test.go @@ -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) {