Skip to content

Commit

Permalink
Improving test to use math/rand/v2
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Schendel <[email protected]>
  • Loading branch information
amitschendel committed Nov 7, 2024
1 parent 23da027 commit f15c5e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ require (
go.opentelemetry.io/otel v1.30.0
go.opentelemetry.io/otel/trace v1.30.0
go.uber.org/multierr v1.11.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/net v0.29.0
golang.org/x/sys v0.25.0
gonum.org/v1/plot v0.14.0
Expand Down Expand Up @@ -228,6 +227,7 @@ require (
go.uber.org/zap v1.27.0 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
Expand Down
5 changes: 3 additions & 2 deletions pkg/dnsmanager/dns_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"sync"
"testing"

"math/rand/v2"

tracerdnstype "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/trace/dns/types"
"golang.org/x/exp/rand"
)

func TestResolveIPAddress(t *testing.T) {
Expand Down Expand Up @@ -202,7 +203,7 @@ func TestConcurrentAccess(t *testing.T) {
// Randomly choose between writing and reading
if rand.Float32() < 0.5 {
// Write operation
event := testEvents[rand.Intn(len(testEvents))]
event := testEvents[rand.IntN(len(testEvents))]
dm.ReportDNSEvent(event)
} else {
// Read operation
Expand Down

0 comments on commit f15c5e9

Please sign in to comment.