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:
Sofia Papagiannaki
2022-11-03 15:21:41 +02:00
committed by GitHub
parent 89548df5a4
commit 5c973e58bd
10 changed files with 854 additions and 86 deletions

10
pkg/util/reverse.go Normal file
View 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
View 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)
}
}