38 lines
585 B
Go
38 lines
585 B
Go
package server
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestIsDir(t *testing.T) {
|
|
if ok := isDir("/tmp"); !ok {
|
|
t.Fatal(ok)
|
|
}
|
|
if ok := isDir("/dev/null"); ok {
|
|
t.Fatal(ok)
|
|
}
|
|
if ok := isDir("/proc/not/real/tho"); ok {
|
|
t.Fatal(ok)
|
|
}
|
|
}
|
|
|
|
func TestLsDir(t *testing.T) {
|
|
dirs, files := lsDir("/usr/local")
|
|
if len(dirs) == 0 {
|
|
t.Fatal(len(dirs))
|
|
}
|
|
if len(files) == 0 {
|
|
t.Fatal(len(files))
|
|
}
|
|
t.Log(dirs)
|
|
t.Log(files)
|
|
}
|
|
|
|
func TestNotesDir(t *testing.T) {
|
|
path := "/usr/local"
|
|
w := httptest.NewRecorder()
|
|
notesDir(path, w, nil)
|
|
t.Logf("%s", w.Body.Bytes())
|
|
}
|