fusenapi/server/home-user-auth/test/basic.go
2023-07-24 19:17:02 +08:00

45 lines
939 B
Go

package homeuserauthtest
import (
"fmt"
authtest "fusenapi/server/auth/test"
"fusenapi/server/home-user-auth/internal/config"
"fusenapi/server/home-user-auth/internal/handler"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/utils/fstests"
"runtime"
"log"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
var cnf config.Config
var userserver *rest.Server
var gserver *rest.Server
func init() {
log.SetFlags(log.Llongfile)
userserver = authtest.GetTestServer()
gserver = GetTestServer()
}
func GetTestServer() *rest.Server {
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
}