testing filetree
parent
a140d0eade
commit
c88fed0929
|
|
@ -1 +1,28 @@
|
||||||
package filetree
|
package filetree
|
||||||
|
|
||||||
|
import (
|
||||||
|
"local/notes-server/config"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDirs(t *testing.T) {
|
||||||
|
config.Root = "/"
|
||||||
|
dirs := NewDirs()
|
||||||
|
info, err := os.Stat("/usr/local")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
p := NewPathFromLocal("/usr")
|
||||||
|
dirs.Push(p, info)
|
||||||
|
if len([]Path(*dirs)) != 1 {
|
||||||
|
t.Error(dirs)
|
||||||
|
}
|
||||||
|
first := []Path(*dirs)[0]
|
||||||
|
if first.Base != "local" {
|
||||||
|
t.Error(first)
|
||||||
|
}
|
||||||
|
if first.Local != "/usr/local" {
|
||||||
|
t.Error(first)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1,28 @@
|
||||||
package filetree
|
package filetree
|
||||||
|
|
||||||
|
import (
|
||||||
|
"local/notes-server/config"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFiles(t *testing.T) {
|
||||||
|
config.Root = "/"
|
||||||
|
files := NewFiles()
|
||||||
|
info, err := os.Stat("/etc/hosts")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
p := NewPathFromLocal("/etc")
|
||||||
|
files.Push(p, info)
|
||||||
|
if len([]Path(*files)) != 1 {
|
||||||
|
t.Error(files)
|
||||||
|
}
|
||||||
|
first := []Path(*files)[0]
|
||||||
|
if first.Base != "hosts" {
|
||||||
|
t.Error(first)
|
||||||
|
}
|
||||||
|
if first.Local != "/etc/hosts" {
|
||||||
|
t.Error(first)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1,30 @@
|
||||||
package filetree
|
package filetree
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPaths(t *testing.T) {
|
||||||
|
paths := Paths([]Path{
|
||||||
|
NewPathFromURL("/notes/a/b"),
|
||||||
|
NewPathFromURL("/notes/c/d"),
|
||||||
|
NewPathFromURL("/notes/e/f"),
|
||||||
|
})
|
||||||
|
|
||||||
|
list := paths.List()
|
||||||
|
if strings.Count(list, "<li>") != 3 {
|
||||||
|
t.Error(list)
|
||||||
|
}
|
||||||
|
if !strings.Contains(list, ">f") {
|
||||||
|
t.Error(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
list = paths.List(true)
|
||||||
|
if strings.Count(list, "<li>") != 3 {
|
||||||
|
t.Error(list)
|
||||||
|
}
|
||||||
|
if !strings.Contains(list, ">/notes/a") {
|
||||||
|
t.Error(list)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue