Base project to template
This commit is contained in:
46
server/.notes/file_test.go
Executable file
46
server/.notes/file_test.go
Executable file
@@ -0,0 +1,46 @@
|
||||
package notes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNotesFile(t *testing.T) {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "until*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(f.Name())
|
||||
fmt.Fprintln(f, `
|
||||
# Hello
|
||||
## World
|
||||
* This
|
||||
* is
|
||||
* bullets
|
||||
|
||||
| My | table | goes |
|
||||
|----|-------|------|
|
||||
| h | e | n |
|
||||
|
||||
`)
|
||||
f.Close()
|
||||
w := httptest.NewRecorder()
|
||||
p := Path{Local: f.Name()}
|
||||
notesFile(p, w, nil)
|
||||
s := string(w.Body.Bytes())
|
||||
shouldContain := []string{
|
||||
"tbody",
|
||||
"h1",
|
||||
"h2",
|
||||
}
|
||||
for _, should := range shouldContain {
|
||||
if !strings.Contains(s, should) {
|
||||
t.Fatalf("%s: %s", should, s)
|
||||
}
|
||||
}
|
||||
t.Logf("%s", s)
|
||||
}
|
||||
Reference in New Issue
Block a user