mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	* For caddy v1 in our org This RP changes all imports for caddyserver/caddy to coredns/caddy. This is the v1 code of caddy. For the coredns/caddy repo the following changes have been made: * anything not needed by us is deleted * all `telemetry` stuff is deleted * all its import paths are also changed to point to coredns/caddy * the v1 branch has been moved to the master branch * a v1.1.0 tag has been added to signal the latest release Signed-off-by: Miek Gieben <miek@miek.nl> * Fix imports Signed-off-by: Miek Gieben <miek@miek.nl> * Group coredns/caddy with out plugins Signed-off-by: Miek Gieben <miek@miek.nl> * remove this file Signed-off-by: Miek Gieben <miek@miek.nl> * Relax import ordering github.com/coredns is now also a coredns dep, this makes github.com/coredns/caddy fit more natural in the list. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix final import Signed-off-by: Miek Gieben <miek@miek.nl>
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package bind
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/coredns/caddy"
 | |
| 	"github.com/coredns/coredns/core/dnsserver"
 | |
| )
 | |
| 
 | |
| func TestSetup(t *testing.T) {
 | |
| 	for i, test := range []struct {
 | |
| 		config   string
 | |
| 		expected []string
 | |
| 		failing  bool
 | |
| 	}{
 | |
| 		{`bind 1.2.3.4`, []string{"1.2.3.4"}, false},
 | |
| 		{`bind`, nil, true},
 | |
| 		{`bind 1.2.3.invalid`, nil, true},
 | |
| 		{`bind 1.2.3.4 ::5`, []string{"1.2.3.4", "::5"}, false},
 | |
| 		{`bind ::1 1.2.3.4 ::5 127.9.9.0`, []string{"::1", "1.2.3.4", "::5", "127.9.9.0"}, false},
 | |
| 		{`bind ::1 1.2.3.4 ::5 127.9.9.0 noone`, nil, true},
 | |
| 	} {
 | |
| 		c := caddy.NewTestController("dns", test.config)
 | |
| 		err := setup(c)
 | |
| 		if err != nil {
 | |
| 			if !test.failing {
 | |
| 				t.Fatalf("Test %d, expected no errors, but got: %v", i, err)
 | |
| 			}
 | |
| 			continue
 | |
| 		}
 | |
| 		if test.failing {
 | |
| 			t.Fatalf("Test %d, expected to failed but did not, returned values", i)
 | |
| 		}
 | |
| 		cfg := dnsserver.GetConfig(c)
 | |
| 		if len(cfg.ListenHosts) != len(test.expected) {
 | |
| 			t.Errorf("Test %d : expected the config's ListenHosts size to be %d, was %d", i, len(test.expected), len(cfg.ListenHosts))
 | |
| 			continue
 | |
| 		}
 | |
| 		for i, v := range test.expected {
 | |
| 			if got, want := cfg.ListenHosts[i], v; got != want {
 | |
| 				t.Errorf("Test %d : expected the config's ListenHost to be %s, was %s", i, want, got)
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |