mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	* auto make -f Makefile.doc Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * Bind by interface name Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * README.md: Interface with multiple address Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * auto make -f Makefile.doc Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * auto make -f Makefile.doc Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * Elaborate more on the behaviour in README.md, revert man/*, fix tests Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * auto make -f Makefile.doc Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * --sign-off Revert man/* to fix DCO check Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> * auto make -f Makefile.doc * Revert man/* to fix DCO check Signed-off-by: Mohammad Yosefpor <myusefpur@gmail.com> Co-authored-by: coredns-auto-go-mod-tidy[bot] <coredns-auto-go-mod-tidy[bot]@users.noreply.github.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.3 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},
 | |
| 		{`bind 1.2.3.4 lo`, []string{"1.2.3.4", "127.0.0.1", "::1"}, false},
 | |
| 	} {
 | |
| 		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)
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |