github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/protocol/alterconfigs/alterconfigs_test.go (about)

     1  package alterconfigs_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/segmentio/kafka-go/protocol/alterconfigs"
     7  	"github.com/segmentio/kafka-go/protocol/prototest"
     8  )
     9  
    10  const (
    11  	v0 = 0
    12  	v1 = 1
    13  )
    14  
    15  func TestAlterConfigsRequest(t *testing.T) {
    16  	prototest.TestRequest(t, v0, &alterconfigs.Request{
    17  		ValidateOnly: true,
    18  		Resources: []alterconfigs.RequestResources{
    19  			{
    20  				ResourceType: 1,
    21  				ResourceName: "foo",
    22  				Configs: []alterconfigs.RequestConfig{
    23  					{
    24  						Name:  "foo",
    25  						Value: "foo",
    26  					},
    27  				},
    28  			},
    29  		},
    30  	})
    31  
    32  	prototest.TestRequest(t, v1, &alterconfigs.Request{
    33  		ValidateOnly: true,
    34  		Resources: []alterconfigs.RequestResources{
    35  			{
    36  				ResourceType: 1,
    37  				ResourceName: "foo",
    38  				Configs: []alterconfigs.RequestConfig{
    39  					{
    40  						Name:  "foo",
    41  						Value: "foo",
    42  					},
    43  				},
    44  			},
    45  		},
    46  	})
    47  }
    48  
    49  func TestAlterConfigsResponse(t *testing.T) {
    50  	prototest.TestResponse(t, v0, &alterconfigs.Response{
    51  		ThrottleTimeMs: 500,
    52  		Responses: []alterconfigs.ResponseResponses{
    53  			{
    54  				ErrorCode:    1,
    55  				ErrorMessage: "foo",
    56  				ResourceType: 1,
    57  				ResourceName: "foo",
    58  			},
    59  		},
    60  	})
    61  
    62  	prototest.TestResponse(t, v1, &alterconfigs.Response{
    63  		ThrottleTimeMs: 500,
    64  		Responses: []alterconfigs.ResponseResponses{
    65  			{
    66  				ErrorCode:    1,
    67  				ErrorMessage: "foo",
    68  				ResourceType: 1,
    69  				ResourceName: "foo",
    70  			},
    71  		},
    72  	})
    73  }