2020-04-28 14:23:52 +03:00
|
|
|
package web_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-07-27 15:22:00 +03:00
|
|
|
"github.com/micro/go-micro/v3/logger"
|
|
|
|
"github.com/micro/go-micro/v3/web"
|
2020-04-28 14:23:52 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWeb(t *testing.T) {
|
2020-07-27 15:22:00 +03:00
|
|
|
for i := 0; i < 3; i++ {
|
2020-04-28 14:23:52 +03:00
|
|
|
fmt.Println("Test nr", i)
|
|
|
|
testFunc()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testFunc() {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*250)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
w := web.NewService(
|
|
|
|
web.Context(ctx),
|
|
|
|
web.HandleSignal(false),
|
|
|
|
)
|
|
|
|
//s.Init()
|
|
|
|
//w.Init()
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
2020-07-27 15:22:00 +03:00
|
|
|
wg.Add(1)
|
2020-04-28 14:23:52 +03:00
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
err := w.Run()
|
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("web run error: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
}
|