Skip to content

Commit

Permalink
broker/test: put request/response in args
Browse files Browse the repository at this point in the history
  • Loading branch information
travisjeffery committed Oct 23, 2017
1 parent f2cd1fc commit 5463e2a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,20 @@ func TestBroker_Run(t *testing.T) {
ctx context.Context
requestc chan jocko.Request
responsec chan jocko.Response
}
type chans struct {
request jocko.Request
response jocko.Response
request jocko.Request
response jocko.Response
}
tests := []struct {
name string
fields fields
args args
chans chans
}{
{
name: "api verions",
fields: newFields(),
args: args{
requestc: make(chan jocko.Request, 2),
responsec: make(chan jocko.Response, 2),
},
chans: chans{
request: jocko.Request{
Header: &protocol.RequestHeader{CorrelationID: 1},
Request: &protocol.APIVersionsRequest{},
Expand Down Expand Up @@ -98,10 +93,10 @@ func TestBroker_Run(t *testing.T) {
}
ctx, cancel := context.WithCancel(context.Background())
go b.Run(ctx, tt.args.requestc, tt.args.responsec)
tt.args.requestc <- tt.chans.request
tt.args.requestc <- tt.args.request
response := <-tt.args.responsec
if !reflect.DeepEqual(response.Response, tt.chans.response.Response) {
t.Errorf("got %v, want: %v", response.Response, tt.chans.response.Response)
if !reflect.DeepEqual(response.Response, tt.args.response.Response) {
t.Errorf("got %v, want: %v", response.Response, tt.args.response.Response)
}
cancel()
})
Expand Down

0 comments on commit 5463e2a

Please sign in to comment.