ci(drone): 添加 Go 模块和构建缓存
- 在 restore cache 和 rebuild cache 步骤中添加了 go-mod-cache 和 go
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// 必须在任何import和g.Cfg()调用前设置环境变量
|
||||
genv.Set("GF_GCFG_FILE", "D:/code/go/epic/manifest/config/config.yaml")
|
||||
genv.Set("GF_GCFG_FILE", "../../../../manifest/config/config.yaml")
|
||||
ctx := gctx.New()
|
||||
_ = g.Cfg().MustGet(ctx, "server.address")
|
||||
fmt.Println(g.Cfg().Get(ctx, "redis.default.address"))
|
||||
@@ -50,17 +50,18 @@ func (m *mockSync) processAndSaveArtifactData(ctx context.Context, data []byte)
|
||||
return m.processArtifactErr
|
||||
}
|
||||
|
||||
//func TestSyncHeroData_Success(t *testing.T) {
|
||||
// sync := &ThirdPartyDataSync{}
|
||||
// // 替换方法为mock
|
||||
// sync.fetchHeroDataFromAPI = (&mockSync{}).fetchHeroDataFromAPI
|
||||
// sync.processAndSaveHeroData = (&mockSync{}).processAndSaveHeroData
|
||||
//
|
||||
// err := sync.SyncHeroData(context.Background())
|
||||
// if err != nil {
|
||||
// t.Errorf("expected success, got error: %v", err)
|
||||
// }
|
||||
//}
|
||||
/**
|
||||
* 测试同步英雄数据
|
||||
*/
|
||||
func TestSyncHeroData(t *testing.T) {
|
||||
thirdPartyDataSync := NewThirdPartyDataSync()
|
||||
|
||||
err := thirdPartyDataSync.SyncHeroData(context.Background())
|
||||
if err != nil {
|
||||
t.Errorf("expected success, got error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//func TestSyncHeroData_FetchError(t *testing.T) {
|
||||
// sync := &ThirdPartyDataSync{}
|
||||
@@ -96,6 +97,7 @@ func (m *mockSync) processAndSaveArtifactData(ctx context.Context, data []byte)
|
||||
//}
|
||||
//
|
||||
//func TestSyncArtifactData_FetchError(t *testing.T) {
|
||||
|
||||
// sync := &ThirdPartyDataSync{}
|
||||
// sync.fetchArtifactDataFromAPI = (&mockSync{fetchArtifactDataErr: errors.New("fetch error")}).fetchArtifactDataFromAPI
|
||||
// sync.processAndSaveArtifactData = (&mockSync{}).processAndSaveArtifactData
|
||||
|
||||
Reference in New Issue
Block a user