package testutil import ( "context" "git.noahlan.cn/noahlan/nnet/v2/internal/codec" "git.noahlan.cn/noahlan/nnet/v2/internal/request" "git.noahlan.cn/noahlan/nnet/v2/internal/response" ctxpkg "git.noahlan.cn/noahlan/nnet/v2/pkg/context" ) // NewTestContext creates a test context with mock connection, request, and response func NewTestContext(parentCtx context.Context, connID string) ctxpkg.Context { if parentCtx == nil { parentCtx = context.Background() } conn := NewMockConnection(connID) req := request.New([]byte("test"), nil) codecRegistry := codec.NewRegistry() resp := response.New(conn, nil, codecRegistry, "json") return ctxpkg.New(parentCtx, conn, req, resp) } // NewTestContextWithData creates a test context with custom request data func NewTestContextWithData(parentCtx context.Context, connID string, data []byte) ctxpkg.Context { if parentCtx == nil { parentCtx = context.Background() } conn := NewMockConnection(connID) req := request.New(data, nil) codecRegistry := codec.NewRegistry() resp := response.New(conn, nil, codecRegistry, "json") return ctxpkg.New(parentCtx, conn, req, resp) }