wheat-cache/pkg/middle/middleware_test.go

32 lines
736 B
Go

package middle
import (
"context"
"testing"
"time"
"gitee.com/timedb/wheatCache/pkg/event"
middleMsg "gitee.com/timedb/wheatCache/pkg/middle-msg"
"github.com/stretchr/testify/require"
)
func Test_middleware_driver(t *testing.T) {
ctx := context.Background()
middleware := NewMiddleWare()
require.Equal(t, middleware.plugins["logcontext"][0].Name(), "logMiddle")
event := event.NewEvent("logcontext")
event.SetValue(middleMsg.MiddleMsgKey, "123")
middleware.eventProduce.Call(ctx, event)
require.Equal(t, middleware.consumerCount, 5)
time.Sleep(1 * time.Second)
}
func TestWorker(t *testing.T) {
// ctx := context.Background()
event := event.NewEvent("logcontext")
m := NewMiddleWare()
m.eventDriver.Put(event)
}