Closed Darrellbor closed 1 year ago
@gavv @ortex PR ready for review
Also @Asalle
Nice work!
a couple of tests could be added:
C endpoint
, e.g. with invalid protocol Protocol(1)
[]float32{}
also, point for discussion (@gavv ):
Maybe add test Receiver_Closed
(or something like that) and remove receiverClosedBefore
scenario from all tests?
Because we need to check that each function call (except Сlose()
) on a closed receiver return an error
e.g:
func TestReceiver_Closed(t *testing.T) {
tests := []struct {
name string
operation func(receiver *Receiver) error
}{
{
name: "SetMulticastGroup after close",
operation: func(receiver *Receiver) error {
return receiver.SetMulticastGroup(SlotDefault, InterfaceAudioSource, "127.0.0.1")
},
},
{
name: "Bind after close",
operation: func(receiver *Receiver) error {
return receiver.Bind(SlotDefault, InterfaceAudioSource, nil)
},
},
{
name: "ReadFloats after close",
operation: func(receiver *Receiver) error {
recFloats := make([]float32, 2)
return receiver.ReadFloats(recFloats)
},
},
}
for _, tt := range tests {
ctx, err := OpenContext(ContextConfig{})
require.NoError(t, err)
require.NotNil(t, ctx)
receiver, err := OpenReceiver(ctx, makeReceiverConfig())
require.NoError(t, err)
require.NotNil(t, receiver)
err = receiver.Close()
require.NoError(t, err)
require.Equal(t, errors.New("receiver is closed"), tt.operation(receiver))
err = ctx.Close()
require.NoError(t, err)
}
}
I agree with Andrey, separating this check will make the table tests more uniform, which is the point of tables. Ideally table tests should have minimal amount of conditions and if tests have rather different flow, they should belong to different tables / tests.
@gavv @ortex reviewed based on the comments and ready for re-review
Thanks!
PR for #41 Implemented
TestReceiver_Bind
TestReceiver_ReadFloats
TestSender_Connect
TestSender_WriteFloats