lib/util: Add caller info to service (ref #5932) (#5973)

This commit is contained in:
Simon Frei
2019-10-16 09:06:16 +02:00
committed by Jakob Borg
parent a0c9db1d09
commit 031684116b
2 changed files with 49 additions and 3 deletions

View File

@@ -6,7 +6,10 @@
package util
import "testing"
import (
"strings"
"testing"
)
type Defaulter struct {
Value string
@@ -222,3 +225,20 @@ func TestCopyMatching(t *testing.T) {
t.Error("NoCopy")
}
}
func TestUtilStopTwicePanic(t *testing.T) {
s := AsService(func(stop chan struct{}) {
<-stop
})
go s.Serve()
s.Stop()
defer func() {
expected := "lib/util.TestUtilStopTwicePanic"
if r := recover(); r == nil || !strings.Contains(r.(string), expected) {
t.Fatalf(`expected panic containing "%v", got "%v"`, expected, r)
}
}()
s.Stop()
}