fusenapi/server/upload/test/basic.go

44 lines
952 B
Go
Raw Normal View History

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