mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(app/edge-stacks): summarize the edge stack statuses in the backend (#818)
This commit is contained in:
parent
363a62d885
commit
e1c480d3c3
21 changed files with 645 additions and 312 deletions
29
api/slicesx/slicesx_test.go
Normal file
29
api/slicesx/slicesx_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package slicesx_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type libFunc[T, U, V any] func([]T, func(T) U) V
|
||||
type predicateFunc[T, U any] func(T) U
|
||||
|
||||
func test[T, U, V any](t *testing.T, libFn libFunc[T, U, V], name string, input []T, expected V, predicate predicateFunc[T, U]) {
|
||||
t.Helper()
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
is := assert.New(t)
|
||||
|
||||
result := libFn(input, predicate)
|
||||
|
||||
switch reflect.TypeOf(result).Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
is.Equal(expected, result)
|
||||
is.ElementsMatch(expected, result)
|
||||
default:
|
||||
is.Equal(expected, result)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue