42 lines
897 B
Go
42 lines
897 B
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"fusenapi/server/home-user-auth/test"
|
||
|
"fusenapi/server/upload/internal/config"
|
||
|
"fusenapi/server/upload/internal/handler"
|
||
|
"fusenapi/server/upload/internal/svc"
|
||
|
"fusenapi/utils/fstests"
|
||
|
"log"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/core/conf"
|
||
|
"github.com/zeromicro/go-zero/rest"
|
||
|
)
|
||
|
|
||
|
var env = "test"
|
||
|
|
||
|
var testConfigFile = "upload.yaml"
|
||
|
var cnf config.Config
|
||
|
var userServer *rest.Server
|
||
|
var gserver *rest.Server
|
||
|
|
||
|
func init() {
|
||
|
log.SetFlags(log.Llongfile)
|
||
|
userServer = test.GetTestServer()
|
||
|
gserver = GetTestServer()
|
||
|
}
|
||
|
|
||
|
func GetTestServer() *rest.Server {
|
||
|
|
||
|
conf.MustLoad(fstests.GetEtcYamlPathAuto(fstests.GetCurrentServiceName()+".yaml"), &cnf)
|
||
|
|
||
|
server := rest.MustNewServer(cnf.RestConf)
|
||
|
defer server.Stop()
|
||
|
|
||
|
ctx := svc.NewServiceContext(cnf)
|
||
|
handler.RegisterHandlers(server, ctx)
|
||
|
|
||
|
fmt.Printf("Starting server at %s:%d...\n", cnf.Host, cnf.Port)
|
||
|
return server
|
||
|
}
|