github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/testutils/utils.go (about)

     1  // Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package testutils
     4  
     5  import (
     6  	"fmt"
     7  	"math/rand"
     8  	"os"
     9  )
    10  
    11  // IsSingleTesting 判断当前测试环境是否为单个函数测试
    12  func IsSingleTesting() bool {
    13  	for _, arg := range os.Args {
    14  		if arg == "-test.run" {
    15  			return true
    16  		}
    17  	}
    18  	return false
    19  }
    20  
    21  // RandIP 生成一个随机IP用于测试
    22  func RandIP() string {
    23  	return fmt.Sprintf("%d.%d.%d.%d", rand.Int()%255, rand.Int()%255, rand.Int()%255, rand.Int()%255)
    24  }