From 88109676e35b35288829f36cf2aa4184d7dbf233 Mon Sep 17 00:00:00 2001 From: guonaihong Date: Sat, 28 Sep 2024 15:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cronex_test.go | 17 ++++++++++++----- go.mod | 12 ++---------- go.sum | 21 ++++----------------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/cronex_test.go b/cronex_test.go index 0014513..86b91dc 100644 --- a/cronex_test.go +++ b/cronex_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/antlabs/timer" - "github.com/stretchr/testify/assert" ) func Test_Cronex(t *testing.T) { @@ -29,7 +28,10 @@ func Test_Cronex(t *testing.T) { durationChan <- time.Since(now) }) - assert.NoError(t, err) + if err != nil { + t.Logf("err(%v)", err) + return + } } // 3s之后关闭 @@ -58,7 +60,10 @@ func Test_Cronex(t *testing.T) { count++ } - assert.NotEqual(t, count, 1, fmt.Sprintf("callback没有调用")) + if count != 1 { + t.Logf("count(%d), count != 1, callback 没有调用", count) + return + } } // 测试下Next函数的时间可正确 @@ -66,8 +71,8 @@ func Test_Cronex_ParseNext(t *testing.T) { var schedule timer.Next schedule, err := standardParser.Parse("* * * * * *") - assert.NoError(t, err) if err != nil { + t.Logf("err(%v)", err) return } @@ -101,5 +106,7 @@ func Test_Multiple(t *testing.T) { time.Sleep(time.Duration(1.1 * float64(time.Second))) cron.Stop() - assert.Equal(t, max, count) + if count != max { + t.Errorf("expected %d, got %d", max, count) + } } diff --git a/go.mod b/go.mod index f7a2713..ba50653 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,6 @@ module github.com/antlabs/cronex go 1.19 -require ( - github.com/antlabs/timer v0.0.11 - github.com/stretchr/testify v1.6.1 -) +require github.com/antlabs/timer v0.1.4 -require ( - github.com/antlabs/stl v0.0.1 // indirect - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.0 // indirect -) +require github.com/antlabs/stl v0.0.2 // indirect diff --git a/go.sum b/go.sum index 37793cf..8fa544f 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,4 @@ -github.com/antlabs/stl v0.0.1 h1:TRD3csCrjREeLhLoQ/supaoCvFhNLBTNIwuRGrDIs6Q= -github.com/antlabs/stl v0.0.1/go.mod h1:wvVwP1loadLG3cRjxUxK8RL4Co5xujGaZlhbztmUEqQ= -github.com/antlabs/timer v0.0.11 h1:z75oGFLeTqJHMOcWzUPBKsBbQAz4Ske3AfqJ7bsdcwU= -github.com/antlabs/timer v0.0.11/go.mod h1:JNV8J3yGvMKhCavGXgj9HXrVZkfdQyKCcqXBT8RdyuU= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +github.com/antlabs/stl v0.0.2 h1:sna1AXR5yIkNE9lWhCcKbheFJSVfCa3vugnGyakI79s= +github.com/antlabs/stl v0.0.2/go.mod h1:kKrO4xrn9cfS1mJVo+/BqePZjAYMXqD0amGF2Ouq7ac= +github.com/antlabs/timer v0.1.4 h1:MHdE00MDnNfhJCmqSOdLXs35uGNwfkMwfbynxrGmQ1c= +github.com/antlabs/timer v0.1.4/go.mod h1:mpw4zlD5KVjstEyUDp43DGLWsY076Mdo4bS78NTseRE=