ocket8888 commented on code in PR #6852:
URL: https://github.com/apache/trafficcontrol/pull/6852#discussion_r881829452
##########
traffic_ops/traffic_ops_golang/test/rand.go:
##########
@@ -36,3 +38,68 @@ func RandStrArray() []string {
}
return sArray
}
+
+func RandBool() *bool {
+ b := rand.Int()%2 == 0
+ return &b
+}
+
+func RandInt() *int {
+ i := rand.Int()
+ return &i
+}
+func RandInt64() *int64 {
+ i := rand.Int63()
+ return &i
+}
+
+func RandUint64() *uint64 {
+ i := uint64(rand.Int63())
+ return &i
+}
+
+func RandUint() *uint {
+ i := uint(rand.Int())
+ return &i
+}
+
+func RandIntn(n int) *int {
+ i := rand.Intn(n)
+ return &i
+}
+
+func RandFloat64() *float64 {
+ f := rand.Float64()
+ return &f
+}
+
+func RandomIPv4() *string {
+ first := rand.Int31n(256)
+ second := rand.Int31n(256)
+ third := rand.Int31n(256)
+ fourth := rand.Int31n(256)
+ str := fmt.Sprintf("%d.%d.%d.%d", first, second, third, fourth)
+ return &str
+}
+
+func RandomIPv6() *string {
+ ip := net.IP([]byte{
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ uint8(rand.Int31n(256)),
+ }).String()
+ return &ip
+}
Review Comment:
GoDocs?
##########
traffic_ops/traffic_ops_golang/crconfig/config_test.go:
##########
@@ -26,13 +26,14 @@ import (
"testing"
"time"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
Review Comment:
By convention we generally leave a blank line between project-internal
imports and external packages
##########
traffic_monitor/threadsafe/resultstathistory_test.go:
##########
@@ -30,6 +29,7 @@ import (
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/traffic_monitor/cache"
"github.com/apache/trafficcontrol/traffic_monitor/srvhttp"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
jsoniter "github.com/json-iterator/go"
Review Comment:
same as above RE: import spacing
##########
traffic_monitor/datareq/datareq_test.go:
##########
@@ -22,14 +22,14 @@ package datareq
import (
"errors"
"math"
- "math/rand"
"testing"
"time"
"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/traffic_monitor/config"
"github.com/apache/trafficcontrol/traffic_monitor/peer"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
Review Comment:
same as above RE: import spacing
##########
traffic_ops/app/db/traffic_vault_migrate/traffic_vault_migrate_test.go:
##########
@@ -20,12 +20,12 @@ package main
*/
import (
- "math/rand"
"reflect"
"strconv"
"strings"
"testing"
+ "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/test"
"github.com/lestrrat-go/jwx/jwk"
Review Comment:
same as above RE: import spacing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]