binwiederhier 2 anni fa
parent
commit
b65044712b
4 ha cambiato i file con 3 aggiunte e 12 eliminazioni
  1. 0 4
      cmd/serve_test.go
  2. 1 1
      server/server_test.go
  3. 2 2
      server/topic_test.go
  4. 0 5
      test/server.go

+ 0 - 4
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

+ 1 - 1
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"

+ 2 - 2
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]

+ 0 - 5
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())