From e6524f925f609bfbf46d965b597daf22a7d9d67a Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 29 Feb 2024 03:15:24 +0100 Subject: [PATCH] Simplify username generation for the tests No need to generate random numbers 10 times, generate a single big-enough one. A single int64 should be more than enough --- internal/tests/tests.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/tests/tests.go b/internal/tests/tests.go index 398771b6..ac173e4b 100644 --- a/internal/tests/tests.go +++ b/internal/tests/tests.go @@ -7,9 +7,9 @@ package tests import ( + "fmt" + "math" "math/rand" - "strconv" - "strings" "testing" miniflux "miniflux.app/v2/client" @@ -27,11 +27,7 @@ const ( ) func getRandomUsername() string { - var suffix []string - for range 10 { - suffix = append(suffix, strconv.Itoa(rand.Intn(1000))) - } - return "user" + strings.Join(suffix, "") + return fmt.Sprintf("user%10d", rand.Intn(math.MaxInt64)) } func createClient(t *testing.T) *miniflux.Client {