aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dirstore_test.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-05-22 23:20:40 +0200
committerRobin Jarry <robin@jarry.cc>2023-05-28 18:21:26 +0200
commit345907914f3e7f131ff9a0fd054a6f772d050636 (patch)
tree41b42236025345a532af5130da0c83ca9aedc886 /lib/dirstore_test.go
parent7cff87b1aef47a6190c177ea862eeac412ca7c39 (diff)
downloadaerc-345907914f3e7f131ff9a0fd054a6f772d050636.tar.gz
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>
Diffstat (limited to 'lib/dirstore_test.go')
-rw-r--r--lib/dirstore_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/dirstore_test.go b/lib/dirstore_test.go
new file mode 100644
index 00000000..b1ba4eb9
--- /dev/null
+++ b/lib/dirstore_test.go
@@ -0,0 +1,23 @@
+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
+ }
+ }
+}