| 1 | package alterclientquotas_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/segmentio/kafka-go/protocol/alterclientquotas" |
| 7 | "github.com/segmentio/kafka-go/protocol/prototest" |
| 8 | ) |
| 9 | |
| 10 | const ( |
| 11 | v0 = 0 |
| 12 | v1 = 1 |
| 13 | ) |
| 14 | |
| 15 | func TestAlterClientQuotasRequest(t *testing.T) { |
| 16 | prototest.TestRequest(t, v0, &alterclientquotas.Request{ |
| 17 | ValidateOnly: true, |
| 18 | Entries: []alterclientquotas.Entry{ |
| 19 | { |
| 20 | Entities: []alterclientquotas.Entity{ |
| 21 | { |
| 22 | EntityType: "client-id", |
| 23 | EntityName: "my-client-id", |
| 24 | }, |
| 25 | }, |
| 26 | Ops: []alterclientquotas.Ops{ |
| 27 | { |
| 28 | Key: "producer_byte_rate", |
| 29 | Value: 1.0, |
| 30 | Remove: false, |
| 31 | }, |
| 32 | }, |
| 33 | }, |
| 34 | }, |
| 35 | }) |
| 36 | |
| 37 | prototest.TestRequest(t, v1, &alterclientquotas.Request{ |
| 38 | ValidateOnly: true, |
| 39 | Entries: []alterclientquotas.Entry{ |
| 40 | { |
| 41 | Entities: []alterclientquotas.Entity{ |
| 42 | { |
| 43 | EntityType: "client-id", |
| 44 | EntityName: "my-client-id", |
| 45 | }, |
| 46 | }, |
| 47 | Ops: []alterclientquotas.Ops{ |
| 48 | { |
| 49 | Key: "producer_byte_rate", |
| 50 | Value: 1.0, |
| 51 | Remove: false, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | }, |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | func TestAlterClientQuotasResponse(t *testing.T) { |
| 60 | prototest.TestResponse(t, v0, &alterclientquotas.Response{ |
| 61 | ThrottleTimeMs: 500, |
| 62 | Results: []alterclientquotas.ResponseQuotas{ |
| 63 | { |
| 64 | ErrorCode: 1, |
| 65 | ErrorMessage: "foo", |
| 66 | Entities: []alterclientquotas.Entity{ |
| 67 | { |
| 68 | EntityType: "client-id", |
| 69 | EntityName: "my-client-id", |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | }, |
| 74 | }) |
| 75 | |
| 76 | prototest.TestResponse(t, v1, &alterclientquotas.Response{ |
| 77 | ThrottleTimeMs: 500, |
| 78 | Results: []alterclientquotas.ResponseQuotas{ |
| 79 | { |
| 80 | ErrorCode: 1, |
| 81 | ErrorMessage: "foo", |
| 82 | Entities: []alterclientquotas.Entity{ |
| 83 | { |
| 84 | EntityType: "client-id", |
| 85 | EntityName: "my-client-id", |
| 86 | }, |
| 87 | }, |
| 88 | }, |
| 89 | }, |
| 90 | }) |
| 91 | } |