1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2025-09-19 01:30:23 +02:00
seaweedfs/weed/mq/kafka/gateway/server_test.go
2025-09-16 23:52:34 -07:00

37 lines
965 B
Go

package gateway
import (
"context"
"github.com/seaweedfs/seaweedfs/weed/mq/kafka/protocol"
)
// NewTestServer creates a server for testing with in-memory handlers
// This should ONLY be used for testing - never in production
// WARNING: This function includes test-only components in production binary
func NewTestServer(opts Options) *Server {
ctx, cancel := context.WithCancel(context.Background())
// Use test handler with storage capability
handler := protocol.NewTestHandler()
return &Server{
opts: opts,
ctx: ctx,
cancel: cancel,
handler: handler,
}
}
// NewTestServerWithHandler creates a test server with a custom handler
// This allows tests to inject specific handlers for different scenarios
func NewTestServerWithHandler(opts Options, handler *protocol.Handler) *Server {
ctx, cancel := context.WithCancel(context.Background())
return &Server{
opts: opts,
ctx: ctx,
cancel: cancel,
handler: handler,
}
}