mirror of https://bitbucket.org/ausocean/av.git
revid: added test for multiSender to check active func function.
Added a test to check that we correctly return from a write call if the multiSenders active callback func return false.
This commit is contained in:
parent
8b93d187c6
commit
42bf44afdf
|
@ -346,6 +346,34 @@ func TestMultiSenderWrite(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: test that active func works
|
||||
// TestMultiSenderNotActiveNoRetry checks that if the active func passed to
|
||||
// newMultiSender returns false before a write, or in the middle of write with
|
||||
// retries, then we return from Write as expected.
|
||||
func TestMultiSenderNotActiveNoRetry(t *testing.T) {
|
||||
senders := []loadSender{
|
||||
newDummyLoadSender(false),
|
||||
newDummyLoadSender(false),
|
||||
newDummyLoadSender(false),
|
||||
}
|
||||
active := true
|
||||
activeFunc := func() bool {
|
||||
return active
|
||||
}
|
||||
ms, err := newMultiSender(senders, false, activeFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
ms.Write([]byte{0x00})
|
||||
active = false
|
||||
ms.Write([]byte{0x01})
|
||||
|
||||
for _, dest := range ms.senders {
|
||||
if len(dest.(*dummyLoadSender).buf) != 1 {
|
||||
t.Errorf("length of sender buf is not 1 as expected")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: test that send retry works
|
||||
// TODO: test that send fail works with no retry
|
||||
|
|
Loading…
Reference in New Issue