2017-07-24 11:39:39 +00:00
|
|
|
package tree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/a8m/tree"
|
|
|
|
"github.com/ncw/rclone/fs"
|
2017-08-01 13:46:21 +00:00
|
|
|
"github.com/ncw/rclone/fstest"
|
2017-07-24 11:39:39 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2018-01-11 16:05:41 +00:00
|
|
|
_ "github.com/ncw/rclone/backend/local"
|
2017-07-24 11:39:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestTree(t *testing.T) {
|
2017-08-01 13:46:21 +00:00
|
|
|
fstest.Initialise()
|
|
|
|
|
2017-07-24 11:39:39 +00:00
|
|
|
buf := new(bytes.Buffer)
|
2017-08-01 13:46:21 +00:00
|
|
|
|
2017-07-24 11:39:39 +00:00
|
|
|
f, err := fs.NewFs("testfiles")
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = Tree(f, buf, new(tree.Options))
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, `/
|
|
|
|
├── file1
|
|
|
|
├── file2
|
|
|
|
├── file3
|
|
|
|
└── subdir
|
|
|
|
├── file4
|
|
|
|
└── file5
|
|
|
|
|
|
|
|
1 directories, 5 files
|
|
|
|
`, buf.String())
|
|
|
|
}
|