MCPcopy Index your code
hub / github.com/riverqueue/river / TestMapError

Function TestMapError

rivershared/util/sliceutil/slice_util_test.go:94–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestMapError(t *testing.T) {
95 t.Parallel()
96
97 result1, err := MapError([]int64{1, 2, 3, 4}, func(x int64) (string, error) {
98 return strconv.FormatInt(x, 10), nil
99 })
100 require.NoError(t, err)
101 require.Equal(t, []string{"1", "2", "3", "4"}, result1)
102
103 _, err = MapError([]int64{1, 2, 3, 4}, func(x int64) (string, error) {
104 if x == 4 {
105 return "", errors.New("error on element 4")
106 }
107 return strconv.FormatInt(x, 10), nil
108 })
109 require.EqualError(t, err, "error on element 4")
110}
111
112func TestUniq(t *testing.T) {
113 t.Parallel()

Callers

nothing calls this directly

Calls 1

MapErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…