aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration
diff options
context:
space:
mode:
authorChongyi Zheng <git@zcy.dev>2024-04-27 12:50:35 -0400
committerGitHub <noreply@github.com>2024-04-27 18:50:35 +0200
commit7b8e418da1e082786b844562a05864ec1177ce97 (patch)
treec42f1034b7ae6a48421f7ddd19a534ab1e7031e6 /tests/integration
parent8de2992ffba8cc627757ecea1e002a55581113d2 (diff)
downloadgitea-1.23.0-dev.tar.gz
gitea-1.23.0-dev.zip
Replace deprecated `math/rand` functions (#30733)v1.23.0-dev
Suggested by logs in #30729 - Remove `math/rand.Seed` `rand.Seed is deprecated: As of Go 1.20 there is no reason to call Seed with a random value.` - Replace `math/rand.Read` `rand.Read is deprecated: For almost all use cases, [crypto/rand.Read] is more appropriate.` - Replace `math/rand` with `math/rand/v2`, which is available since Go 1.22
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/benchmarks_test.go6
-rw-r--r--tests/integration/git_test.go2
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/integration/benchmarks_test.go b/tests/integration/benchmarks_test.go
index 7a882fe836..62da761d2d 100644
--- a/tests/integration/benchmarks_test.go
+++ b/tests/integration/benchmarks_test.go
@@ -4,7 +4,7 @@
package integration
import (
- "math/rand"
+ "math/rand/v2"
"net/http"
"net/url"
"testing"
@@ -18,7 +18,7 @@ import (
func StringWithCharset(length int, charset string) string {
b := make([]byte, length)
for i := range b {
- b[i] = charset[rand.Intn(len(charset))]
+ b[i] = charset[rand.IntN(len(charset))]
}
return string(b)
}
@@ -37,7 +37,7 @@ func BenchmarkRepoBranchCommit(b *testing.B) {
b.ResetTimer()
b.Run("CreateBranch", func(b *testing.B) {
b.StopTimer()
- branchName := StringWithCharset(5+rand.Intn(10), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+ branchName := StringWithCharset(5+rand.IntN(10), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
b.StartTimer()
for i := 0; i < b.N; i++ {
b.Run("new_"+branchName, func(b *testing.B) {
diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go
index 818e1fa653..74c511fd7e 100644
--- a/tests/integration/git_test.go
+++ b/tests/integration/git_test.go
@@ -5,9 +5,9 @@ package integration
import (
"bytes"
+ "crypto/rand"
"encoding/hex"
"fmt"
- "math/rand"
"net/http"
"net/url"
"os"