38 lines
525 B
Go
38 lines
525 B
Go
package services_test
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
type TestData struct {
|
|
Name string
|
|
Age int32
|
|
}
|
|
|
|
func (this *TestData) Log() {
|
|
sys.Errorln("妈妈咪呀!")
|
|
}
|
|
|
|
var sys log.ISys
|
|
|
|
func TestMain(m *testing.M) {
|
|
var err error
|
|
if sys, err = log.NewSys(
|
|
log.SetFileName("log.log"),
|
|
log.SetIsDebug(false),
|
|
log.SetEncoder(log.TextEncoder),
|
|
); err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer os.Exit(m.Run())
|
|
}
|
|
func Test_sys(t *testing.T) {
|
|
data := &TestData{}
|
|
data.Log()
|
|
|
|
}
|