| 1 | package apiversions_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/segmentio/kafka-go/protocol/apiversions" |
| 7 | "github.com/segmentio/kafka-go/protocol/prototest" |
| 8 | ) |
| 9 | |
| 10 | const ( |
| 11 | v0 = 0 |
| 12 | v1 = 1 |
| 13 | v2 = 2 |
| 14 | ) |
| 15 | |
| 16 | func TestApiversionsRequest(t *testing.T) { |
| 17 | prototest.TestRequest(t, v0, &apiversions.Request{}) |
| 18 | |
| 19 | prototest.TestRequest(t, v1, &apiversions.Request{}) |
| 20 | |
| 21 | prototest.TestRequest(t, v2, &apiversions.Request{}) |
| 22 | } |
| 23 | |
| 24 | func TestApiversionsResponse(t *testing.T) { |
| 25 | prototest.TestResponse(t, v0, &apiversions.Response{ |
| 26 | ErrorCode: 0, |
| 27 | ApiKeys: []apiversions.ApiKeyResponse{ |
| 28 | { |
| 29 | ApiKey: 0, |
| 30 | MinVersion: 0, |
| 31 | MaxVersion: 2, |
| 32 | }, |
| 33 | }, |
| 34 | }) |
| 35 | |
| 36 | prototest.TestResponse(t, v1, &apiversions.Response{ |
| 37 | ErrorCode: 0, |
| 38 | ApiKeys: []apiversions.ApiKeyResponse{ |
| 39 | { |
| 40 | ApiKey: 0, |
| 41 | MinVersion: 0, |
| 42 | MaxVersion: 2, |
| 43 | }, |
| 44 | }, |
| 45 | ThrottleTimeMs: 10, |
| 46 | }) |
| 47 | |
| 48 | prototest.TestResponse(t, v2, &apiversions.Response{ |
| 49 | ErrorCode: 0, |
| 50 | ApiKeys: []apiversions.ApiKeyResponse{ |
| 51 | { |
| 52 | ApiKey: 0, |
| 53 | MinVersion: 0, |
| 54 | MaxVersion: 2, |
| 55 | }, |
| 56 | }, |
| 57 | ThrottleTimeMs: 50, |
| 58 | }) |
| 59 | } |