MCPcopy
hub / github.com/segmentio/kafka-go / TestCreateTopicsResponse

Function TestCreateTopicsResponse

createtopics_test.go:163–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func TestCreateTopicsResponse(t *testing.T) {
164 supportedVersions := []apiVersion{v0, v1, v2}
165 for _, v := range supportedVersions {
166 item := createTopicsResponse{
167 v: v,
168 TopicErrors: []createTopicsResponseTopicError{
169 {
170 v: v,
171 Topic: "topic",
172 ErrorCode: 2,
173 },
174 },
175 }
176
177 b := bytes.NewBuffer(nil)
178 w := &writeBuffer{w: b}
179 item.writeTo(w)
180
181 found := createTopicsResponse{v: v}
182 remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
183 if err != nil {
184 t.Error(err)
185 t.FailNow()
186 }
187 if remain != 0 {
188 t.Errorf("expected 0 remain, got %v", remain)
189 t.FailNow()
190 }
191 if !reflect.DeepEqual(item, found) {
192 t.Error("expected item and found to be the same")
193 t.FailNow()
194 }
195 }
196}

Callers

nothing calls this directly

Calls 5

writeToMethod · 0.95
NewReaderMethod · 0.65
LenMethod · 0.65
readFromMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected