mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	, so that `make test` will pass by default. Also fixed several ineffassign and golint issues. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package test
 | |
| 
 | |
| import (
 | |
| 	"io/ioutil"
 | |
| 	"log"
 | |
| 	"net/http"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestHealthReload(t *testing.T) {
 | |
| 	log.SetOutput(ioutil.Discard)
 | |
| 
 | |
| 	// Corefile with for example without proxy section.
 | |
| 	corefile := `example.org:0 {
 | |
| 	health localhost:35080
 | |
| }
 | |
| `
 | |
| 	i, err := CoreDNSServer(corefile)
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("Could not get CoreDNS serving instance: %s", err)
 | |
| 	}
 | |
| 
 | |
| 	resp, err := http.Get("http://localhost:35080/health")
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("Could not get health: %s", err)
 | |
| 	}
 | |
| 	body, err := ioutil.ReadAll(resp.Body)
 | |
| 	if x := string(body); x != "OK" {
 | |
| 		t.Fatalf("Expect OK, got %s", x)
 | |
| 	}
 | |
| 	resp.Body.Close()
 | |
| 
 | |
| 	i, err = i.Restart(NewInput(corefile))
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("Could not restart CoreDNS serving instance: %s", err)
 | |
| 	}
 | |
| 
 | |
| 	defer i.Stop()
 | |
| 
 | |
| 	resp, err = http.Get("http://localhost:35080/health")
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("Could not get health: %s", err)
 | |
| 	}
 | |
| 	body, err = ioutil.ReadAll(resp.Body)
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("Could not get resp.Body: %s", err)
 | |
| 	}
 | |
| 	if x := string(body); x != "OK" {
 | |
| 		t.Fatalf("Expect OK, got %s", x)
 | |
| 	}
 | |
| 	resp.Body.Close()
 | |
| }
 |