Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1729f129a | ||
|
|
f61302d25f |
@@ -168,7 +168,10 @@ func (cli *Client) Connect() {
|
|||||||
}
|
}
|
||||||
cli.port = fmt.Sprintf("%d", listener.Addr().(*net.TCPAddr).Port)
|
cli.port = fmt.Sprintf("%d", listener.Addr().(*net.TCPAddr).Port)
|
||||||
|
|
||||||
router := gin.Default()
|
router := gin.New()
|
||||||
|
router.Use(gin.Recovery())
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
|
||||||
router.POST("/:label", func(c *gin.Context) {
|
router.POST("/:label", func(c *gin.Context) {
|
||||||
label := c.Param("label")
|
label := c.Param("label")
|
||||||
if f, ok := cli.register.Load(label); ok {
|
if f, ok := cli.register.Load(label); ok {
|
||||||
|
|||||||
@@ -5,8 +5,30 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestSelectChan(t *testing.T) {
|
||||||
|
var a chan string = make(chan string)
|
||||||
|
var b chan string = make(chan string)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
|
a <- "1"
|
||||||
|
time.Sleep(time.Second * 2)
|
||||||
|
b <- "2"
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case s := <-a:
|
||||||
|
log.Println("a", s)
|
||||||
|
case s := <-b:
|
||||||
|
log.Println("b", s)
|
||||||
|
case <-time.After(time.Second * 5):
|
||||||
|
log.Println("timeout 5s")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPort(t *testing.T) {
|
func TestPort(t *testing.T) {
|
||||||
cli := New("http://localhost:7123")
|
cli := New("http://localhost:7123")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user