github.com/weplanx/server@v0.2.6-0.20240318110640-f7e75155779a/api/tencent/common_test.go (about)

     1  package tencent_test
     2  
     3  import (
     4  	"context"
     5  	"github.com/weplanx/server/api"
     6  	"github.com/weplanx/server/bootstrap"
     7  	"github.com/weplanx/server/common"
     8  	"os"
     9  	"testing"
    10  	"time"
    11  )
    12  
    13  var (
    14  	x *api.API
    15  )
    16  
    17  func TestMain(m *testing.M) {
    18  	os.Chdir("../../")
    19  	var err error
    20  	var values *common.Values
    21  	if values, err = bootstrap.LoadStaticValues("./config/default.values.yml"); err != nil {
    22  		panic(err)
    23  	}
    24  	x, err = bootstrap.NewAPI(values)
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
    29  	defer cancel()
    30  	if _, err = x.Initialize(ctx); err != nil {
    31  		panic(err)
    32  	}
    33  	time.Sleep(time.Second)
    34  	os.Exit(m.Run())
    35  }