From 5d06a87d82a135230db8713ba5a61a0d40e9751c Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 11 Nov 2015 17:27:25 -0800 Subject: [PATCH] Adds an RPC endpoint injection method for testing. --- consul/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/consul/server.go b/consul/server.go index 83602c4272..eec5802127 100644 --- a/consul/server.go +++ b/consul/server.go @@ -689,6 +689,12 @@ func (s *Server) RPC(method string, args interface{}, reply interface{}) error { return codec.err } +// InjectEndpoint is used to substitute an endpoint for testing. +func (s *Server) InjectEndpoint(endpoint interface{}) error { + s.logger.Printf("[WARN] consul: endpoint injected; this should only be used for testing") + return s.rpcServer.Register(endpoint) +} + // Stats is used to return statistics for debugging and insight // for various sub-systems func (s *Server) Stats() map[string]map[string]string {