Documentation
¶
Overview ¶
Package testutil provides utilities for testing with mindns. It exposes an in-process test server for integration testing.
Index ¶
- type Config
- type TestServer
- func (s *TestServer) CreateZone(ctx context.Context, name string) error
- func (s *TestServer) DNSAddr() string
- func (s *TestServer) DNSPort() int
- func (s *TestServer) GRPCAddr() string
- func (s *TestServer) GRPCPort() int
- func (s *TestServer) Manager() *zone.Manager
- func (s *TestServer) Start() error
- func (s *TestServer) StartBackground()
- func (s *TestServer) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DNSPort is the port for the DNS server (0 for auto-assign)
DNSPort int
// GRPCPort is the port for the gRPC server (0 for auto-assign)
GRPCPort int
}
Config configures the test server.
type TestServer ¶
type TestServer struct {
// contains filtered or unexported fields
}
TestServer is an in-process mindns server for testing. It runs both DNS and gRPC servers with an in-memory store.
func NewTestServer ¶
func NewTestServer(cfg Config) (*TestServer, error)
NewTestServer creates a new test server with in-memory storage. Call Start() to begin serving requests.
func (*TestServer) CreateZone ¶
func (s *TestServer) CreateZone(ctx context.Context, name string) error
CreateZone is a convenience method to create a test zone.
func (*TestServer) DNSAddr ¶
func (s *TestServer) DNSAddr() string
DNSAddr returns the DNS server address (e.g., "127.0.0.1:5353").
func (*TestServer) DNSPort ¶
func (s *TestServer) DNSPort() int
DNSPort returns the DNS server port.
func (*TestServer) GRPCAddr ¶
func (s *TestServer) GRPCAddr() string
GRPCAddr returns the gRPC server address (e.g., "127.0.0.1:50051").
func (*TestServer) GRPCPort ¶
func (s *TestServer) GRPCPort() int
GRPCPort returns the gRPC server port.
func (*TestServer) Manager ¶
func (s *TestServer) Manager() *zone.Manager
Manager returns the zone manager for direct manipulation in tests.
func (*TestServer) Start ¶
func (s *TestServer) Start() error
Start begins serving DNS and gRPC requests. This method blocks until the server is stopped. For non-blocking operation, call StartBackground().
func (*TestServer) StartBackground ¶
func (s *TestServer) StartBackground()
StartBackground starts the servers in background goroutines. Returns immediately after starting.