mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
test(view): improve test coverage (#7543)
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>
This commit is contained in:
22
plugin/view/metadata_test.go
Normal file
22
plugin/view/metadata_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user