package service_test import ( "fmt" "apigo.cc/gojs" _ "apigo.cc/gojs/console" _ "apigo.cc/gojs/http" _ "apigo.cc/gojs/service" _ "apigo.cc/gojs/util" "github.com/ssgo/u" //"go.uber.org/goleak" //_ "net/http/pprof" "runtime" "testing" ) var rt3 *gojs.Runtime func TestStartWSByPool(t *testing.T) { gojs.ExportForDev() rt3 = gojs.New() err := rt3.StartFromFile("start_ws.js") if err != nil { t.Fatal("start failed", err) } _, err = rt3.RunMain() if err != nil { t.Fatal("start failed", err) } } func TestWS(t *testing.T) { r, err := rt3.RunCode("testWS()") if err != nil { t.Fatal("test ws failed, got error", err) } else if r != true { t.Fatal("test ws failed", r, err) } else { fmt.Println(u.BGreen("test ws success")) } } func TestStopWSByPool(t *testing.T) { _, err := rt3.RunCode("s.stop()") if err != nil { t.Fatal("stop failed", err) } gojs.WaitAll() runtime.GC() ms3 := runtime.MemStats{} runtime.ReadMemStats(&ms3) fmt.Println(u.Cyan("END MEMORY >>"), u.BCyan(ms3.HeapInuse/1000000)) }