mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	This PR adds the *root* middleware that specifies a path where all zone file (the *file* middleware is the only consumer now) can be found. It works the same as in Caddy. Documentation can be found in the README.md of the middleware. Fixes #307
		
			
				
	
	
		
			42 lines
		
	
	
		
			825 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			825 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package secondary
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/mholt/caddy"
 | 
						|
)
 | 
						|
 | 
						|
// TODO(miek): this only check the syntax.
 | 
						|
func TestSecondaryParse(t *testing.T) {
 | 
						|
	tests := []struct {
 | 
						|
		inputFileRules string
 | 
						|
		shouldErr      bool
 | 
						|
		transferFrom   string
 | 
						|
	}{
 | 
						|
		{
 | 
						|
			`secondary`,
 | 
						|
			false, // TODO(miek): should actually be true, because without transfer lines this does not make sense
 | 
						|
			"",
 | 
						|
		},
 | 
						|
		{
 | 
						|
			`secondary {
 | 
						|
				transfer from 127.0.0.1
 | 
						|
				transfer to 127.0.0.1
 | 
						|
			}`,
 | 
						|
			false,
 | 
						|
			"",
 | 
						|
		},
 | 
						|
	}
 | 
						|
 | 
						|
	for i, test := range tests {
 | 
						|
		c := caddy.NewTestController("dns", test.inputFileRules)
 | 
						|
		_, err := secondaryParse(c)
 | 
						|
 | 
						|
		if err == nil && test.shouldErr {
 | 
						|
			t.Fatalf("Test %d expected errors, but got no error", i)
 | 
						|
		} else if err != nil && !test.shouldErr {
 | 
						|
			t.Fatalf("Test %d expected no errors, but got '%v'", i, err)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |