diff options
Diffstat (limited to 'expvarhandler/expvar_test.go')
-rw-r--r-- | expvarhandler/expvar_test.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/expvarhandler/expvar_test.go b/expvarhandler/expvar_test.go index e6114d7..6fa1d0d 100644 --- a/expvarhandler/expvar_test.go +++ b/expvarhandler/expvar_test.go @@ -4,17 +4,24 @@ import ( "encoding/json" "expvar" "strings" + "sync" "testing" "github.com/valyala/fasthttp" ) +var once sync.Once + func TestExpvarHandlerBasic(t *testing.T) { t.Parallel() - expvar.Publish("customVar", expvar.Func(func() any { - return "foobar" - })) + // Publish panics if the same var is published more than once, + // which can happen if the test is run with -count + once.Do(func() { + expvar.Publish("customVar", expvar.Func(func() any { + return "foobar" + })) + }) var ctx fasthttp.RequestCtx |