From b65044712b42390b169116bb67f0aeb4b08b72c7 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Thu, 16 Nov 2023 21:04:49 -0500 Subject: [PATCH] Fix linter --- cmd/serve_test.go | 4 ---- server/server_test.go | 2 +- server/topic_test.go | 4 ++-- test/server.go | 5 ----- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/serve_test.go b/cmd/serve_test.go index 9e16540b..748adbd8 100644 --- a/cmd/serve_test.go +++ b/cmd/serve_test.go @@ -17,10 +17,6 @@ import ( "heckel.io/ntfy/v2/util" ) -func init() { - rand.Seed(time.Now().UnixMilli()) -} - func TestCLI_Serve_Unix_Curl(t *testing.T) { sockFile := filepath.Join(t.TempDir(), "ntfy.sock") configFile := newEmptyFile(t) // Avoid issues with existing server.yml file on system diff --git a/server/server_test.go b/server/server_test.go index d387c359..5f2bac6a 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -3,13 +3,13 @@ package server import ( "bufio" "context" + "crypto/rand" "encoding/base64" "encoding/json" "fmt" "golang.org/x/crypto/bcrypt" "heckel.io/ntfy/v2/user" "io" - "math/rand" "net/http" "net/http/httptest" "net/netip" diff --git a/server/topic_test.go b/server/topic_test.go index 41a29cfd..8de16111 100644 --- a/server/topic_test.go +++ b/server/topic_test.go @@ -69,7 +69,7 @@ func TestTopic_Subscribe_DuplicateID(t *testing.T) { t.Parallel() to := newTopic("mytopic") - // Fix random seed to force same number generation + //lint:ignore SA1019 Fix random seed to force same number generation rand.Seed(1) a := rand.Int() to.subscribers[a] = &topicSubscriber{ @@ -82,7 +82,7 @@ func TestTopic_Subscribe_DuplicateID(t *testing.T) { return nil } - // Force rand.Int to generate the same id once more + //lint:ignore SA1019 Force rand.Int to generate the same id once more rand.Seed(1) id := to.Subscribe(subFn, "b", func() {}) res := to.subscribers[id] diff --git a/test/server.go b/test/server.go index 18529359..9d75a2c7 100644 --- a/test/server.go +++ b/test/server.go @@ -7,13 +7,8 @@ import ( "net/http" "path/filepath" "testing" - "time" ) -func init() { - rand.Seed(time.Now().UnixMilli()) -} - // StartServer starts a server.Server with a random port and waits for the server to be up func StartServer(t *testing.T) (*server.Server, int) { return StartServerWithConfig(t, server.NewConfig())