package rclone import ( "io/ioutil" "os" "path" "sort" "strconv" "testing" ) func TestList(t *testing.T) { rc, def := makeRC() defer def() d, err := ioutil.TempDir(os.TempDir(), "list.*") if err != nil { t.Fatal(err) } for i := 0; i < 3; i++ { if err := ioutil.WriteFile(path.Join(d, strconv.Itoa(i)), []byte("hi"), os.ModePerm); err != nil { t.Fatal(err) } } names, err := rc.List("local:" + d) if err != nil { t.Fatal(err) } if len(names) != 3 { t.Fatal(len(names)) } sort.Strings(names) for i := range names { if names[i] != strconv.Itoa(i) { t.Error(names[i]) } } }