github.com/wfusion/gofusion@v1.1.14/test/log/cases/log_test.go (about) 1 package cases 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/stretchr/testify/suite" 8 9 "github.com/wfusion/gofusion/log" 10 11 testLog "github.com/wfusion/gofusion/test/log" 12 ) 13 14 func TestLog(t *testing.T) { 15 testingSuite := &Log{Test: new(testLog.Test)} 16 testingSuite.Init(testingSuite) 17 suite.Run(t, testingSuite) 18 } 19 20 type Log struct { 21 *testLog.Test 22 } 23 24 func (t *Log) BeforeTest(suiteName, testName string) { 25 t.Catch(func() { 26 log.Info(context.Background(), "right before %s %s", suiteName, testName) 27 }) 28 } 29 30 func (t *Log) AfterTest(suiteName, testName string) { 31 t.Catch(func() { 32 log.Info(context.Background(), "right after %s %s", suiteName, testName) 33 }) 34 } 35 36 func (t *Log) TestLevel() { 37 t.Catch(func() { 38 logger := log.Use("default", log.AppName(t.AppName())) 39 40 // When 41 ctx, cancel := context.WithCancel(context.Background()) 42 defer cancel() 43 44 // Then 45 t.EqualValues(log.DebugLevel, logger.Level(ctx)) 46 }) 47 }