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
This commit is contained in:
jvoisin 2024-02-29 03:15:24 +01:00 committed by Frédéric Guillot
parent c493f8921e
commit e6524f925f
1 changed files with 3 additions and 7 deletions

View File

@ -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 {