mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 18:23:13 -04:00 
			
		
		
		
	* Update Caddy to 1.0.1, and update import path This fix updates caddy to 1.0.1 and also updates the import path to github.com/caddyserver/caddy This fix fixes 2959 Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Also update plugin.cfg Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update and bump zplugin.go Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
		
			
				
	
	
		
			43 lines
		
	
	
		
			903 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			903 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package metrics
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/caddyserver/caddy"
 | |
| )
 | |
| 
 | |
| func TestPrometheusParse(t *testing.T) {
 | |
| 	tests := []struct {
 | |
| 		input     string
 | |
| 		shouldErr bool
 | |
| 		addr      string
 | |
| 	}{
 | |
| 		// oks
 | |
| 		{`prometheus`, false, "localhost:9153"},
 | |
| 		{`prometheus localhost:53`, false, "localhost:53"},
 | |
| 		// fails
 | |
| 		{`prometheus {}`, true, ""},
 | |
| 		{`prometheus /foo`, true, ""},
 | |
| 		{`prometheus a b c`, true, ""},
 | |
| 	}
 | |
| 	for i, test := range tests {
 | |
| 		c := caddy.NewTestController("dns", test.input)
 | |
| 		m, err := parse(c)
 | |
| 		if test.shouldErr && err == nil {
 | |
| 			t.Errorf("Test %v: Expected error but found nil", i)
 | |
| 			continue
 | |
| 		} else if !test.shouldErr && err != nil {
 | |
| 			t.Errorf("Test %v: Expected no error but found error: %v", i, err)
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		if test.shouldErr {
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		if test.addr != m.Addr {
 | |
| 			t.Errorf("Test %v: Expected address %s but found: %s", i, test.addr, m.Addr)
 | |
| 		}
 | |
| 	}
 | |
| }
 |