Files
EdgeNode/internal/utils/testutils/utils.go

25 lines
532 B
Go
Raw Permalink Normal View History

2024-07-27 15:42:50 +08:00
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
2023-06-07 21:49:42 +08:00
package testutils
2024-03-31 10:08:53 +08:00
import (
"fmt"
"math/rand"
"os"
)
2023-06-07 21:49:42 +08:00
// IsSingleTesting 判断当前测试环境是否为单个函数测试
func IsSingleTesting() bool {
for _, arg := range os.Args {
if arg == "-test.run" {
return true
}
}
return false
2024-03-31 10:08:53 +08:00
}
// RandIP 生成一个随机IP用于测试
func RandIP() string {
return fmt.Sprintf("%d.%d.%d.%d", rand.Int()%255, rand.Int()%255, rand.Int()%255, rand.Int()%255)
}