From 93f29a7598dee07bd606ebfcae9516cae8e92e1b Mon Sep 17 00:00:00 2001 From: Karthic Rao Date: Fri, 3 Jul 2015 10:03:22 +0530 Subject: [PATCH] preliminary test case for config/setup/markdown.go --- config/setup/markdown_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 config/setup/markdown_test.go diff --git a/config/setup/markdown_test.go b/config/setup/markdown_test.go new file mode 100644 index 00000000..bbfb6913 --- /dev/null +++ b/config/setup/markdown_test.go @@ -0,0 +1,33 @@ +package setup + +import ( + "github.com/mholt/caddy/middleware/markdown" + "testing" +) + +func TestMarkdown(t *testing.T) { + + c := NewTestController(`markdown /blog`) + + mid, err := Markdown(c) + + if err != nil { + t.Errorf("Expected no errors, got: %v", err) + } + + if mid == nil { + t.Fatal("Expected middleware, was nil instead") + } + + handler := mid(EmptyNext) + myHandler, ok := handler.(markdown.Markdown) + + if !ok { + t.Fatalf("Expected handler to be type Markdown, got: %#v", handler) + } + + if myHandler.Configs[0].PathScope != "/blog" { + t.Errorf("Expected /blog as the Path Scope") + } + +}