Implement tree command - fixes #1528
This commit is contained in:
parent
bfef0bc2e9
commit
f3060caf04
8 changed files with 264 additions and 0 deletions
36
cmd/tree/tree_test.go
Normal file
36
cmd/tree/tree_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package tree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/a8m/tree"
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
_ "github.com/ncw/rclone/local"
|
||||
)
|
||||
|
||||
func TestTree(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
// Never ask for passwords, fail instead.
|
||||
// If your local config is encrypted set environment variable
|
||||
// "RCLONE_CONFIG_PASS=hunter2" (or your password)
|
||||
*fs.AskPassword = false
|
||||
fs.LoadConfig()
|
||||
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())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue