Skip to content

Commit

Permalink
detect unit testing and skip init
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Mill <jeremymill@gmail.com>
  • Loading branch information
LivingInSyn authored and poiana committed Apr 23, 2022
1 parent 8ff7964 commit ab29121
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"strings"

"github.com/DataDog/datadog-go/statsd"
Expand Down Expand Up @@ -60,6 +61,13 @@ var (
)

func init() {
// detect unit testing and skip init.
// see: https://github.com/alecthomas/kingpin/issues/187
testing := (strings.HasSuffix(os.Args[0], ".test") ||
strings.HasSuffix(os.Args[0], "__debug_bin"))
if testing {
return
}
config = getConfig()
stats = getInitStats()
promStats = getInitPromStats(config)
Expand Down

0 comments on commit ab29121

Please sign in to comment.