mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	Cover edge cases in config parser. Add rudimentary View/Filter tests. Improves test coverage from 44% to 82%. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
		
			
				
	
	
		
			23 lines
		
	
	
		
			535 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			535 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package view
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/coredns/coredns/plugin/metadata"
 | 
						|
	"github.com/coredns/coredns/request"
 | 
						|
)
 | 
						|
 | 
						|
func TestMetadata_PublishesViewName(t *testing.T) {
 | 
						|
	v := &View{viewName: "myview"}
 | 
						|
	ctx := metadata.ContextWithMetadata(context.Background())
 | 
						|
	st := request.Request{}
 | 
						|
	ctx = v.Metadata(ctx, st)
 | 
						|
 | 
						|
	if f := metadata.ValueFunc(ctx, "view/name"); f == nil {
 | 
						|
		t.Fatalf("metadata value func is nil")
 | 
						|
	} else if got := f(); got != "myview" {
 | 
						|
		t.Fatalf("metadata value: got %q, want %q", got, "myview")
 | 
						|
	}
 | 
						|
}
 |