45 lines
927 B
Go
45 lines
927 B
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
authtest "fusenapi/server/auth/test"
|
|
"fusenapi/server/upload/internal/config"
|
|
"fusenapi/server/upload/internal/handler"
|
|
"fusenapi/server/upload/internal/svc"
|
|
"fusenapi/utils/fstests"
|
|
"log"
|
|
"runtime"
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
"github.com/zeromicro/go-zero/rest"
|
|
)
|
|
|
|
var cnf config.Config
|
|
|
|
var userver, gserver *rest.Server
|
|
|
|
func init() {
|
|
log.SetFlags(log.Llongfile)
|
|
userver = authtest.GetTestServer()
|
|
gserver = GetTestServer()
|
|
}
|
|
|
|
func GetTestServer() *rest.Server {
|
|
|
|
// log.Println(fstests.GetEtcYamlPathAuto())
|
|
conf.MustLoad(fstests.GetEtcYamlPathAuto(), &cnf)
|
|
server := rest.MustNewServer(cnf.RestConf)
|
|
runtime.SetFinalizer(server, func(server *rest.Server) {
|
|
if server != nil {
|
|
server.Stop()
|
|
}
|
|
})
|
|
|
|
ctx := svc.NewServiceContext(cnf)
|
|
handler.RegisterHandlers(server, ctx)
|
|
|
|
fmt.Printf("Starting server at %s:%d...\n", cnf.Host, cnf.Port)
|
|
return server
|
|
}
|