2017-07-24 13:39:39 +02:00
|
|
|
package tree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2020-11-05 16:18:51 +01:00
|
|
|
"context"
|
2017-07-24 13:39:39 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/a8m/tree"
|
2019-07-28 19:47:38 +02:00
|
|
|
_ "github.com/rclone/rclone/backend/local"
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
|
|
"github.com/rclone/rclone/fstest"
|
2017-07-24 13:39:39 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTree(t *testing.T) {
|
2017-08-01 15:46:21 +02:00
|
|
|
fstest.Initialise()
|
|
|
|
|
2017-07-24 13:39:39 +02:00
|
|
|
buf := new(bytes.Buffer)
|
2017-08-01 15:46:21 +02:00
|
|
|
|
2020-11-05 16:18:51 +01:00
|
|
|
f, err := fs.NewFs(context.Background(), "testfiles")
|
2017-07-24 13:39:39 +02:00
|
|
|
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())
|
|
|
|
}
|