Skip to content

Commit

Permalink
add protocol/apiversions unit test (segmentio#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenju authored Jul 2, 2021
1 parent 7113876 commit 45672af
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions protocol/apiversions/apiversions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package apiversions_test

import (
"testing"

"github.com/segmentio/kafka-go/protocol/apiversions"
"github.com/segmentio/kafka-go/protocol/prototest"
)

const (
v0 = 0
v1 = 1
v2 = 2
)

func TestApiversionsRequest(t *testing.T) {
prototest.TestRequest(t, v0, &apiversions.Request{})

prototest.TestRequest(t, v1, &apiversions.Request{})

prototest.TestRequest(t, v2, &apiversions.Request{})
}

func TestApiversionsResponse(t *testing.T) {
prototest.TestResponse(t, v0, &apiversions.Response{
ErrorCode: 0,
ApiKeys: []apiversions.ApiKeyResponse{
{
ApiKey: 0,
MinVersion: 0,
MaxVersion: 2,
},
},
})

prototest.TestResponse(t, v1, &apiversions.Response{
ErrorCode: 0,
ApiKeys: []apiversions.ApiKeyResponse{
{
ApiKey: 0,
MinVersion: 0,
MaxVersion: 2,
},
},
ThrottleTimeMs: 10,
})

prototest.TestResponse(t, v2, &apiversions.Response{
ErrorCode: 0,
ApiKeys: []apiversions.ApiKeyResponse{
{
ApiKey: 0,
MinVersion: 0,
MaxVersion: 2,
},
},
ThrottleTimeMs: 50,
})
}

0 comments on commit 45672af

Please sign in to comment.