mirror of https://github.com/rwxrob/bonzai
Modify util.Files to return relative paths
parent
06bc522037
commit
01a3a765e3
@ -1,43 +1,50 @@
|
||||
package util_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/rwxrob/bonzai/filter"
|
||||
"github.com/rwxrob/bonzai/loop"
|
||||
"github.com/rwxrob/bonzai/util"
|
||||
)
|
||||
|
||||
func ExampleFiles() {
|
||||
filter.Println(util.Files("testdata/files"))
|
||||
loop.Println(util.Files("testdata/files"))
|
||||
// Output:
|
||||
// bar
|
||||
// blah
|
||||
// dir1/
|
||||
// dir2/
|
||||
// dir3/
|
||||
// foo
|
||||
// other
|
||||
// some
|
||||
// testdata/files/bar
|
||||
// testdata/files/blah
|
||||
// testdata/files/dir1/
|
||||
// testdata/files/dir2/
|
||||
// testdata/files/dir3/
|
||||
// testdata/files/foo
|
||||
// testdata/files/other
|
||||
// testdata/files/some
|
||||
}
|
||||
|
||||
func ExampleFiles_empty() {
|
||||
os.Chdir("testdata/files")
|
||||
defer os.Chdir("../..")
|
||||
filter.Println(util.Files(""))
|
||||
loop.Println(util.Files(""))
|
||||
// Output:
|
||||
// bar
|
||||
// blah
|
||||
// dir1/
|
||||
// dir2/
|
||||
// dir3/
|
||||
// foo
|
||||
// other
|
||||
// some
|
||||
// ./bar
|
||||
// ./blah
|
||||
// ./dir1/
|
||||
// ./dir2/
|
||||
// ./dir3/
|
||||
// ./foo
|
||||
// ./other
|
||||
// ./some
|
||||
}
|
||||
|
||||
func ExampleFilesWith() {
|
||||
filter.Println(util.FilesWith("testdata/files", "b"))
|
||||
loop.Println(util.FilesWith("testdata/files", "b"))
|
||||
// Output:
|
||||
// bar
|
||||
// blah
|
||||
// testdata/files/bar
|
||||
// testdata/files/blah
|
||||
}
|
||||
|
||||
func ExampleFiles_not_Directory() {
|
||||
fmt.Println(util.Files("none"))
|
||||
// Output:
|
||||
// []
|
||||
}
|
||||
|
Loading…
Reference in New Issue