mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-11 14:39:09 -06:00
groupware: add /bootstrap
* add a GET /accounts/{a}/boostrap URI that delivers the same as GET /
but also mailboxes for a given account, in case the UI remembers the
last used account identifier, to avoid an additional roundtrip
* streamline the use of simpleError()
* add logging of errors at the calling site
* add logging of evictions of Sessions from the cache
* change default Session cache TTL to 5min instead of 30sec
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
package structs
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
orderedmap "github.com/wk8/go-ordered-map"
|
||||
)
|
||||
|
||||
@@ -30,3 +33,11 @@ func Uniq[T comparable](source []T) []T {
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
func Keys[K comparable, V any](source map[K]V) []K {
|
||||
if source == nil {
|
||||
var zero []K
|
||||
return zero
|
||||
}
|
||||
return slices.Collect(maps.Keys(source))
|
||||
}
|
||||
|
||||
@@ -83,3 +83,19 @@ func TestUniqWithStructs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeys(t *testing.T) {
|
||||
tests := []struct {
|
||||
input map[int]string
|
||||
expected []int
|
||||
}{
|
||||
{map[int]string{5: "cinq", 1: "un", 3: "trois", 4: "vier"}, []int{5, 1, 3, 4}},
|
||||
{map[int]string{1: "un"}, []int{1}},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d: testing %v", i+1, tt.input), func(t *testing.T) {
|
||||
result := Keys(tt.input)
|
||||
assert.ElementsMatch(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user