mirror of
https://github.com/gone-io/gone.git
synced 2025-01-23 01:00:23 +08:00
test: add test cases
This commit is contained in:
parent
18dc70cf4a
commit
26e19db397
@ -725,3 +725,41 @@ func Test_cemetery_getGonerContainerByType(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
var afterReviveOrder = make([]int, 0)
|
||||
var startOrder = make([]int, 0)
|
||||
var stopOrder = make([]int, 0)
|
||||
|
||||
type ordered struct {
|
||||
Flag
|
||||
order int
|
||||
}
|
||||
|
||||
func (o *ordered) AfterRevive() error {
|
||||
afterReviveOrder = append(afterReviveOrder, o.order)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ordered) Start(Cemetery) error {
|
||||
startOrder = append(startOrder, o.order)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ordered) Stop(Cemetery) error {
|
||||
stopOrder = append(stopOrder, o.order)
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestOrder(t *testing.T) {
|
||||
Prepare(func(cemetery Cemetery) error {
|
||||
cemetery.
|
||||
Bury(&ordered{order: 2}, Order(2)).
|
||||
Bury(&ordered{order: 1}, Order(1)).
|
||||
Bury(&ordered{order: 3}, Order(3))
|
||||
return nil
|
||||
}).Test(func() {})
|
||||
|
||||
assert.Equal(t, []int{1, 2, 3}, afterReviveOrder)
|
||||
assert.Equal(t, []int{3, 2, 1}, startOrder)
|
||||
assert.Equal(t, []int{1, 2, 3}, stopOrder)
|
||||
}
|
||||
|
11
logger.go
11
logger.go
@ -31,9 +31,6 @@ func (l *defaultLogger) Infof(format string, args ...any) {
|
||||
func (l *defaultLogger) Warnf(format string, args ...any) {
|
||||
log.Printf(format, args...)
|
||||
}
|
||||
func (l *defaultLogger) Warningf(format string, args ...any) {
|
||||
log.Printf(format, args...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Errorf(format string, args ...any) {
|
||||
log.Printf(format, args...)
|
||||
@ -51,9 +48,7 @@ func (l *defaultLogger) Info(args ...any) {
|
||||
func (l *defaultLogger) Warn(args ...any) {
|
||||
log.Print(args...)
|
||||
}
|
||||
func (l *defaultLogger) Warning(args ...any) {
|
||||
log.Print(args...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Error(args ...any) {
|
||||
log.Print(args...)
|
||||
}
|
||||
@ -70,9 +65,7 @@ func (l *defaultLogger) Infoln(args ...any) {
|
||||
func (l *defaultLogger) Warnln(args ...any) {
|
||||
log.Println(args...)
|
||||
}
|
||||
func (l *defaultLogger) Warningln(args ...any) {
|
||||
log.Println(args...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Errorln(args ...any) {
|
||||
log.Println(args...)
|
||||
}
|
||||
|
@ -14,21 +14,22 @@ func Test_defaultLogger_Tracef(t *testing.T) {
|
||||
log.Debugf("format: %s", "test")
|
||||
log.Infof("format: %s", "test")
|
||||
log.Warnf("format: %s", "test")
|
||||
//log.Warningf("format: %s", "test")
|
||||
log.Errorf("format: %s", "test")
|
||||
|
||||
log.Trace("test")
|
||||
log.Debug("test")
|
||||
log.Info("test")
|
||||
log.Warn("test")
|
||||
//log.Warning("test")
|
||||
log.Error("test")
|
||||
|
||||
log.Traceln("test")
|
||||
log.Debugln("test")
|
||||
log.Infoln("test")
|
||||
log.Warnln("test")
|
||||
//log.Warningln("test")
|
||||
log.Errorln("test")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetSimpleLogger(t *testing.T) {
|
||||
assert.Equal(t, _defaultLogger, GetSimpleLogger())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user