mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Nested Folders: Add tests for store methods (#57662)
* Nested Folders: Add store tests * Fix parent order * Fix update * skip tests! * Export test helpers for now
This commit is contained in:
committed by
GitHub
parent
89548df5a4
commit
5c973e58bd
10
pkg/util/reverse.go
Normal file
10
pkg/util/reverse.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package util
|
||||
|
||||
// Reverse returns a new slice with reversed order
|
||||
func Reverse[T comparable](input []T) []T {
|
||||
output := make([]T, 0, len(input))
|
||||
for i := len(input) - 1; i >= 0; i-- {
|
||||
output = append(output, input[i])
|
||||
}
|
||||
return output
|
||||
}
|
15
pkg/util/reverse_test.go
Normal file
15
pkg/util/reverse_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestReverse(t *testing.T) {
|
||||
input := []int{1, 2, 3, 4, 5}
|
||||
|
||||
if diff := cmp.Diff([]int{5, 4, 3, 2, 1}, Reverse(input)); diff != "" {
|
||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user