github.com/vseinstrumentiru/lego@v1.0.2/run_test.go (about) 1 package LeGo 2 3 import ( 4 "context" 5 lego2 "github.com/vseinstrumentiru/lego/internal/lego" 6 "github.com/vseinstrumentiru/lego/pkg/lego" 7 "io" 8 "testing" 9 "time" 10 ) 11 12 type app struct { 13 lego.LogErr 14 } 15 16 func (a *app) GetName() string { 17 return "Test App" 18 } 19 20 func (a *app) SetLogErr(logger lego.LogErr) { 21 a.LogErr = logger 22 } 23 24 func (a *app) Register(p lego2.Process) (io.Closer, error) { 25 a.Info("application registered") 26 27 return nil, nil 28 } 29 30 func TestServer_Run(t *testing.T) { 31 ctx, cancel := context.WithCancel(context.Background()) 32 go func() { 33 time.Sleep(3 * time.Second) 34 cancel() 35 }() 36 Run(ctx, &app{}) 37 }