1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-07-11 01:30:22 +02:00
aerc/lib/dirstore_test.go
Koni Marti 345907914f dirstore: list the folders in arrival order
List the folders in arrival order when dirstore.List() is called instead
of returning it in an arbitrary order.

If enable-folders-sort=false and dirlist-tree=false, the directory list
will arbitrarly reshuffle when changing directories because the
dirlist.dirs are generated from keys in a map in the dirstore.

Fixes: https://todo.sr.ht/~rjarry/aerc/178
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-05-28 18:21:26 +02:00

23 lines
448 B
Go

package lib_test
import (
"reflect"
"testing"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/models"
)
func TestDirStore_List(t *testing.T) {
dirs := []string{"a/c", "x", "a/b", "d"}
dirstore := lib.NewDirStore()
for _, d := range dirs {
dirstore.SetMessageStore(&models.Directory{Name: d}, nil)
}
for i := 0; i < 10; i++ {
if !reflect.DeepEqual(dirstore.List(), dirs) {
t.Errorf("order does not match")
return
}
}
}