MCPcopy
hub / github.com/destel/rill / TestFromChan

Function TestFromChan

wrap_test.go:78–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestFromChan(t *testing.T) {
79 t.Run("nil", func(t *testing.T) {
80 res := FromChan[int](nil, nil)
81 th.ExpectValue(t, res, nil)
82 })
83
84 t.Run("no error", func(t *testing.T) {
85 var inSlice []int
86 var expectedOutSlice []Try[int]
87
88 for i := 0; i < 20000; i++ {
89 inSlice = append(inSlice, i)
90 expectedOutSlice = append(expectedOutSlice, Try[int]{Value: i})
91 }
92
93 wrapped := FromChan(th.FromSlice(inSlice), nil)
94 outSlice := th.ToSlice(wrapped)
95
96 th.ExpectSlice(t, outSlice, expectedOutSlice)
97 })
98
99 t.Run("with error", func(t *testing.T) {
100 var inSlice []int
101 var expectedOutSlice []Try[int]
102
103 err := fmt.Errorf("err")
104 expectedOutSlice = append(expectedOutSlice, Try[int]{Error: err})
105
106 for i := 0; i < 20000; i++ {
107 inSlice = append(inSlice, i)
108 expectedOutSlice = append(expectedOutSlice, Try[int]{Value: i})
109 }
110
111 wrapped := FromChan(th.FromSlice(inSlice), err)
112 outSlice := th.ToSlice(wrapped)
113
114 th.ExpectSlice(t, outSlice, expectedOutSlice)
115 })
116}
117
118func TestFromChans(t *testing.T) {
119 // slices -> FromSlice -> FromChans -> ToChans -> ToSlice -> compare

Callers

nothing calls this directly

Calls 5

ExpectValueFunction · 0.92
FromSliceFunction · 0.92
ToSliceFunction · 0.92
ExpectSliceFunction · 0.92
FromChanFunction · 0.85

Tested by

no test coverage detected