1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-24 12:19:13 +01:00

Fix linter

This commit is contained in:
binwiederhier 2023-11-16 21:04:49 -05:00
parent 22f48c5ad3
commit b65044712b
4 changed files with 3 additions and 12 deletions

View file

@ -17,10 +17,6 @@ import (
"heckel.io/ntfy/v2/util" "heckel.io/ntfy/v2/util"
) )
func init() {
rand.Seed(time.Now().UnixMilli())
}
func TestCLI_Serve_Unix_Curl(t *testing.T) { func TestCLI_Serve_Unix_Curl(t *testing.T) {
sockFile := filepath.Join(t.TempDir(), "ntfy.sock") sockFile := filepath.Join(t.TempDir(), "ntfy.sock")
configFile := newEmptyFile(t) // Avoid issues with existing server.yml file on system configFile := newEmptyFile(t) // Avoid issues with existing server.yml file on system

View file

@ -3,13 +3,13 @@ package server
import ( import (
"bufio" "bufio"
"context" "context"
"crypto/rand"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"heckel.io/ntfy/v2/user" "heckel.io/ntfy/v2/user"
"io" "io"
"math/rand"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/netip" "net/netip"

View file

@ -69,7 +69,7 @@ func TestTopic_Subscribe_DuplicateID(t *testing.T) {
t.Parallel() t.Parallel()
to := newTopic("mytopic") 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) rand.Seed(1)
a := rand.Int() a := rand.Int()
to.subscribers[a] = &topicSubscriber{ to.subscribers[a] = &topicSubscriber{
@ -82,7 +82,7 @@ func TestTopic_Subscribe_DuplicateID(t *testing.T) {
return nil 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) rand.Seed(1)
id := to.Subscribe(subFn, "b", func() {}) id := to.Subscribe(subFn, "b", func() {})
res := to.subscribers[id] res := to.subscribers[id]

View file

@ -7,13 +7,8 @@ import (
"net/http" "net/http"
"path/filepath" "path/filepath"
"testing" "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 // 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) { func StartServer(t *testing.T) (*server.Server, int) {
return StartServerWithConfig(t, server.NewConfig()) return StartServerWithConfig(t, server.NewConfig())