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
43
api/slicesx/map_test.go
Normal file
43
api/slicesx/map_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package slicesx_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/portainer/portainer/api/slicesx"
|
||||
)
|
||||
|
||||
func Test_Map(t *testing.T) {
|
||||
test(t, slicesx.Map, "Map integers to strings",
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
[]string{"1", "2", "3", "4", "5"},
|
||||
strconv.Itoa,
|
||||
)
|
||||
test(t, slicesx.Map, "Map strings to integers",
|
||||
[]string{"1", "2", "3", "4", "5"},
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
func(s string) int {
|
||||
n, _ := strconv.Atoi(s)
|
||||
return n
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func Test_FlatMap(t *testing.T) {
|
||||
test(t, slicesx.FlatMap, "Map integers to strings and flatten",
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
[]string{"1", "1", "2", "2", "3", "3", "4", "4", "5", "5"},
|
||||
func(i int) []string {
|
||||
x := strconv.Itoa(i)
|
||||
return []string{x, x}
|
||||
},
|
||||
)
|
||||
test(t, slicesx.FlatMap, "Map strings to integers and flatten",
|
||||
[]string{"1", "2", "3", "4", "5"},
|
||||
[]int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5},
|
||||
func(s string) []int {
|
||||
n, _ := strconv.Atoi(s)
|
||||
return []int{n, n}
|
||||
},
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue