1
mirror of https://github.com/rclone/rclone synced 2024-12-22 13:03:02 +01:00
rclone/cmd/tree/tree_test.go
Nick Craig-Wood d846210978 fs: Add context to NewFs #3257 #4685
This adds a context.Context parameter to NewFs and related calls.

This is necessary as part of reading config from the context -
backends need to be able to read the global config.
2020-11-09 18:05:54 +00:00

36 lines
659 B
Go

package tree
import (
"bytes"
"context"
"testing"
"github.com/a8m/tree"
_ "github.com/rclone/rclone/backend/local"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fstest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTree(t *testing.T) {
fstest.Initialise()
buf := new(bytes.Buffer)
f, err := fs.NewFs(context.Background(), "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())
}