weldr: replace use of deprecated rand.Seed with New(NewSource(seed))
"rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator."
This commit is contained in:
parent
f98169c29a
commit
356a222b83
1 changed files with 8 additions and 4 deletions
|
|
@ -774,9 +774,10 @@ func TestBlueprintsDelete(t *testing.T) {
|
|||
func TestBlueprintsChanges(t *testing.T) {
|
||||
api, sf := createTestWeldrAPI(t.TempDir(), test_distro.TestDistro1Name, test_distro.TestArchName, rpmmd_mock.BaseFixture, nil)
|
||||
t.Cleanup(sf.Cleanup)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
// math/rand is good enough in this case
|
||||
/* #nosec G404 */
|
||||
rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
/* #nosec G404 */
|
||||
id := strconv.Itoa(rand.Int())
|
||||
ignoreFields := []string{"commit", "timestamp"}
|
||||
|
||||
|
|
@ -800,9 +801,10 @@ func TestBlueprintsChanges(t *testing.T) {
|
|||
func TestBlueprintChange(t *testing.T) {
|
||||
api, sf := createTestWeldrAPI(t.TempDir(), test_distro.TestDistro1Name, test_distro.TestArchName, rpmmd_mock.BaseFixture, nil)
|
||||
t.Cleanup(sf.Cleanup)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
// math/rand is good enough in this case
|
||||
/* #nosec G404 */
|
||||
rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
/* #nosec G404 */
|
||||
id := strconv.Itoa(rand.Int())
|
||||
|
||||
test.SendHTTP(api, true, "POST", "/api/v0/blueprints/new", `{"name":"`+id+`","description":"Test","packages":[{"name":"httpd","version":"2.4.*"}],"version":"0.0.1"}`)
|
||||
|
|
@ -860,9 +862,10 @@ func TestBlueprintsDepsolve(t *testing.T) {
|
|||
func TestOldBlueprintsUndo(t *testing.T) {
|
||||
api, sf := createTestWeldrAPI(t.TempDir(), test_distro.TestDistro1Name, test_distro.TestArchName, rpmmd_mock.OldChangesFixture, nil)
|
||||
t.Cleanup(sf.Cleanup)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
// math/rand is good enough in this case
|
||||
/* #nosec G404 */
|
||||
rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
/* #nosec G404 */
|
||||
ignoreFields := []string{"commit", "timestamp"}
|
||||
|
||||
test.TestRoute(t, api, true, "GET", "/api/v0/blueprints/changes/test-old-changes", ``, http.StatusOK, oldBlueprintsUndoResponse, ignoreFields...)
|
||||
|
|
@ -895,9 +898,10 @@ func TestOldBlueprintsUndo(t *testing.T) {
|
|||
func TestNewBlueprintsUndo(t *testing.T) {
|
||||
api, sf := createTestWeldrAPI(t.TempDir(), test_distro.TestDistro1Name, test_distro.TestArchName, rpmmd_mock.BaseFixture, nil)
|
||||
t.Cleanup(sf.Cleanup)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
// math/rand is good enough in this case
|
||||
/* #nosec G404 */
|
||||
rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
/* #nosec G404 */
|
||||
id := strconv.Itoa(rand.Int())
|
||||
ignoreFields := []string{"commit", "timestamp"}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue