Commit bc2feece authored by Maxime's avatar Maxime

Moved test files to testdata folder.

Changed the tests accordingly.
parent 2df30d18
......@@ -101,7 +101,7 @@ func TestSort(t *testing.T) {
}
func TestBrowseTemplate(t *testing.T) {
tmpl, err := template.ParseFiles("photos.tpl")
tmpl, err := template.ParseFiles("testdata/photos.tpl")
if err != nil {
t.Fatalf("An error occured while parsing the template: %v", err)
}
......@@ -111,7 +111,7 @@ func TestBrowseTemplate(t *testing.T) {
t.Fatalf("Next shouldn't be called")
return 0, nil
}),
Root: ".",
Root: "./testdata",
Configs: []Config{
Config{
PathScope: "/photos",
......
......@@ -3,6 +3,7 @@
package markdown
import (
"fmt"
"io/ioutil"
"net/http"
"os"
......@@ -125,6 +126,7 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
URL: r.URL,
}
html, err := md.Process(m, fpath, body, ctx)
fmt.Printf("%v", html)
if err != nil {
return http.StatusInternalServerError, err
}
......
......@@ -6,15 +6,16 @@ import (
"strings"
"testing"
"github.com/mholt/caddy/middleware"
"github.com/russross/blackfriday"
)
func TestMarkdown(t *testing.T) {
templates := make(map[string]string)
templates[DefaultTemplate] = "markdown_tpl.html"
templates[DefaultTemplate] = "testdata/markdown_tpl.html"
md := Markdown{
Root: "/blog",
FileSys: http.Dir("."),
Root: "./testdata",
FileSys: http.Dir("./testdata"),
Configs: []Config{
Config{
Renderer: blackfriday.HtmlRenderer(0, "", ""),
......@@ -34,6 +35,10 @@ func TestMarkdown(t *testing.T) {
},
},
IndexFiles: []string{"index.html"},
Next: middleware.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) {
t.Fatalf("Next shouldn't be called")
return 0, nil
}),
}
req, err := http.NewRequest("GET", "/blog/test.md", nil)
......
......@@ -2,6 +2,7 @@ package markdown
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
......@@ -106,6 +107,7 @@ func (md Markdown) processTemplate(c Config, requestPath string, tmpl []byte, me
// nothing fatal, only log the error.
// TODO: Report this non-fatal error, but don't log it here
log.Println(err)
fmt.Printf("Error: %v", err)
}
return b.Bytes(), nil
......
......@@ -25,8 +25,8 @@ func Test(t *testing.T) {
Path: "/images",
},
},
Root: ".",
FileSys: http.Dir("."),
Root: "./testdata",
FileSys: http.Dir("./testdata"),
}
tmplroot := Templates{
......@@ -40,8 +40,8 @@ func Test(t *testing.T) {
Path: "/",
},
},
Root: ".",
FileSys: http.Dir("."),
Root: "./testdata",
FileSys: http.Dir("./testdata"),
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment