mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	Remove these 2 channels, as they were only used in testing and complicate things if we want to do a clean stop() Less is more.
		
			
				
	
	
		
			34 lines
		
	
	
		
			586 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			586 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package forward
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/coredns/coredns/plugin/pkg/dnstest"
 | 
						|
 | 
						|
	"github.com/miekg/dns"
 | 
						|
)
 | 
						|
 | 
						|
func TestPersistent(t *testing.T) {
 | 
						|
	s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
 | 
						|
		ret := new(dns.Msg)
 | 
						|
		ret.SetReply(r)
 | 
						|
		w.WriteMsg(ret)
 | 
						|
	})
 | 
						|
	defer s.Close()
 | 
						|
 | 
						|
	tr := newTransport(s.Addr, nil /* no TLS */)
 | 
						|
	defer tr.Stop()
 | 
						|
 | 
						|
	c1, cache1, _ := tr.Dial("udp")
 | 
						|
	c2, cache2, _ := tr.Dial("udp")
 | 
						|
	c3, cache3, _ := tr.Dial("udp")
 | 
						|
 | 
						|
	if cache1 || cache2 || cache3 {
 | 
						|
		t.Errorf("Expected non-cached connection")
 | 
						|
	}
 | 
						|
 | 
						|
	tr.Yield(c1)
 | 
						|
	tr.Yield(c2)
 | 
						|
	tr.Yield(c3)
 | 
						|
}
 |