mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-26 21:19:31 +02:00
databroker: fix fast forward (#4194)
databroker: fix fast forward (#4192) * databroker: sort configs * databroker: fix fast-forward * newest not oldest Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
This commit is contained in:
parent
ca59798540
commit
4aa6960e06
4 changed files with 113 additions and 47 deletions
32
pkg/slices/slices_test.go
Normal file
32
pkg/slices/slices_test.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package slices
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestReverse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, tc := range []struct {
|
||||
in []int
|
||||
expect []int
|
||||
}{
|
||||
{in: []int{1, 2, 3}, expect: []int{3, 2, 1}},
|
||||
{in: []int{1, 2}, expect: []int{2, 1}},
|
||||
{in: []int{1}, expect: []int{1}},
|
||||
} {
|
||||
s := make([]int, len(tc.in))
|
||||
copy(s, tc.in)
|
||||
Reverse(s)
|
||||
assert.Equal(t, tc.expect, s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUniqueBy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := UniqueBy([]int{1, 2, 3, 4, 3, 1, 1, 4, 2}, func(i int) int { return i % 3 })
|
||||
assert.Equal(t, []int{1, 2, 3}, s)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue