第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

具有外部包依賴性的 Golang 測試未通過 Gitlab Ci,但通過本地

具有外部包依賴性的 Golang 測試未通過 Gitlab Ci,但通過本地

Go
千巷貓影 2023-06-05 16:52:28
我有測試:package miscvar (    Trace   *log.Logger    Info    *log.Logger    Warning *log.Logger    Error   *log.Logger)func TestFTPGetFilesFromServer(t *testing.T) {    misc.InitLogger(4) }with InitLogger is located in another packagefunc InitSimpleLogger(level int) {    if level == 1 {        Trace = log.New(ioutil.Discard, "[TRACE]\t", log.Ldate|log.Ltime|log.Lshortfile)        Info = log.New(ioutil.Discard, "[INFO]\t", log.Ldate|log.Ltime|log.Lshortfile)        Warning = log.New(ioutil.Discard, "[WARNING]\t", log.Ldate|log.Ltime|log.Lshortfile)        Error = log.New(os.Stdout, "[ERROR]\t", log.Ldate|log.Ltime|log.Lshortfile)    } else if level == 2 {        Trace = log.New(ioutil.Discard, "[TRACE]\t", log.Ldate|log.Ltime|log.Lshortfile)        Info = log.New(ioutil.Discard, "[INFO]\t", log.Ldate|log.Ltime|log.Lshortfile)        Warning = log.New(os.Stdout, "[WARNING]\t", log.Ldate|log.Ltime|log.Lshortfile)        Error = log.New(os.Stdout, "[ERROR]\t", log.Ldate|log.Ltime|log.Lshortfile)    } else if level == 3 {        Trace = log.New(os.Stdout, "[TRACE]\t", log.Ldate|log.Ltime|log.Lshortfile)        Info = log.New(ioutil.Discard, "[INFO]\t", log.Ldate|log.Ltime|log.Lshortfile)        Warning = log.New(os.Stdout, "[WARNING]\t", log.Ldate|log.Ltime|log.Lshortfile)        Error = log.New(os.Stdout, "[ERROR]\t", log.Ldate|log.Ltime|log.Lshortfile)    } else {        Trace = log.New(os.Stdout, "[TRACE]\t", log.Ldate|log.Ltime|log.Lshortfile)        Info = log.New(os.Stdout, "[INFO]\t", log.Ldate|log.Ltime|log.Lshortfile)        Warning = log.New(os.Stdout, "[WARNING]\t", log.Ldate|log.Ltime|log.Lshortfile)        Error = log.New(os.Stdout, "[ERROR]\t", log.Ldate|log.Ltime|log.Lshortfile)    }}
查看完整描述

1 回答

?
蕪湖不蕪

TA貢獻1796條經(jīng)驗 獲得超7個贊

測試不確保misc.InitSimpleLogger(4)在依賴此函數(shù)調(diào)用的副作用的測試之前執(zhí)行。將調(diào)用移至函數(shù)init()以確保它在測試之前執(zhí)行。改變

func TestFTPGetFilesFromServer(t *testing.T) {
    misc.InitLogger(4) 
}

func init() {
    misc.InitLogger(4) 
}


查看完整回答
反對 回復(fù) 2023-06-05
  • 1 回答
  • 0 關(guān)注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號