diff --git a/revid/senders_test.go b/revid/senders_test.go index 360e540e..a6d1d298 100644 --- a/revid/senders_test.go +++ b/revid/senders_test.go @@ -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