diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-26 20:33:37 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-26 20:33:37 +0200 |
commit | 4534dffb865eb1a50bfbc291a5c3798183081caf (patch) | |
tree | d5bd1a2d9912a6442e3be1511ffb1d99f12287b0 /pkg/u/util_test.go | |
parent | 349a3d1ff36a436261b1b65b870f8f262f06584f (diff) | |
download | cerrado-4534dffb865eb1a50bfbc291a5c3798183081caf.tar.gz cerrado-4534dffb865eb1a50bfbc291a5c3798183081caf.tar.bz2 cerrado-4534dffb865eb1a50bfbc291a5c3798183081caf.zip |
feat: Add actual git listing implementation
Diffstat (limited to 'pkg/u/util_test.go')
-rw-r--r-- | pkg/u/util_test.go | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/pkg/u/util_test.go b/pkg/u/util_test.go deleted file mode 100644 index a6d84c7..0000000 --- a/pkg/u/util_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// go:build unit - -package u - -import ( - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestFirst(t *testing.T) { - testCases := []struct { - name string - slice []int - first int - exist bool - }{ - { - name: "multiple items slice", - slice: []int{1, 2, 3}, - first: 1, - exist: true, - }, - { - name: "single item slice", - slice: []int{1}, - first: 1, - exist: true, - }, - { - name: "empty slice", - slice: []int{}, - first: 0, - exist: false, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - - first, empty := First(tc.slice) - - if first != tc.first { - t.Errorf("Error first, want %d got %d", tc.first, first) - } - - if empty != tc.exist { - t.Errorf("Error empty, want %t got %t", tc.exist, empty) - } - - }) - } -} - -func TestSubList(t *testing.T) { - testCases := []struct { - name string - slice []int - size int - want [][]int - }{ - { - name: "sigle size sub list", - slice: []int{1, 2, 3}, - size: 1, - want: [][]int{{1}, {2}, {3}}, - }, - { - name: "multiple size sub list", - slice: []int{1, 2, 3, 4}, - size: 2, - want: [][]int{{1, 2}, {3, 4}}, - }, - { - name: "uneven multiple size sub list", - slice: []int{1, 2, 3, 4, 5}, - size: 2, - want: [][]int{{1, 2}, {3, 4}, {5}}, - }, - { - name: "empty sub list", - slice: []int{}, - size: 2, - want: [][]int{{}}, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - - subList := ChunkBy(tc.slice, tc.size) - - if diff := cmp.Diff(tc.want, subList); diff != "" { - t.Errorf("Wrong result given - wanted + got\n %s", diff) - } - }) - } -} |