From e5f95d1ea0977b78a576a41f272d98137a776b78 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 23 Apr 2019 13:18:41 +0930 Subject: [PATCH] revid: addressing PR feedback --- container/mts/audio_test.go | 2 +- container/mts/metaEncode_test.go | 4 ++-- revid/revid_test.go | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/container/mts/audio_test.go b/container/mts/audio_test.go index 053bb0a9..9ef1f883 100644 --- a/container/mts/audio_test.go +++ b/container/mts/audio_test.go @@ -74,7 +74,7 @@ func TestEncodePcm(t *testing.T) { } } } - clip := (*bytes.Buffer)(&buf).Bytes() + clip := buf.Bytes() // Get the first MTS packet to check var pkt packet.Packet diff --git a/container/mts/metaEncode_test.go b/container/mts/metaEncode_test.go index 314e235a..7fc23252 100644 --- a/container/mts/metaEncode_test.go +++ b/container/mts/metaEncode_test.go @@ -53,7 +53,7 @@ func TestMetaEncode1(t *testing.T) { if err := e.writePSI(); err != nil { t.Errorf(errUnexpectedErr, err.Error()) } - out := (*bytes.Buffer)(&buf).Bytes() + out := buf.Bytes() got := out[PacketSize+4:] want := []byte{ @@ -82,7 +82,7 @@ func TestMetaEncode2(t *testing.T) { if err := e.writePSI(); err != nil { t.Errorf(errUnexpectedErr, err.Error()) } - out := (*bytes.Buffer)(&buf).Bytes() + out := buf.Bytes() got := out[PacketSize+4:] want := []byte{ 0x00, 0x02, 0xb0, 0x36, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x24, diff --git a/revid/revid_test.go b/revid/revid_test.go index 145e4825..5134b47d 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -95,21 +95,33 @@ func (tl *testLogger) Log(level int8, msg string, params ...interface{}) { // tstMtsEncoder emulates the mts.Encoder to the extent of the dst field. // This will allow access to the dst to check that it has been set corrctly. -type tstMtsEncoder struct{ dst io.WriteCloser } +type tstMtsEncoder struct { + // dst is here soley to detect the type stored in the encoder. + // No data is written to dst. + dst io.WriteCloser +} func (e *tstMtsEncoder) Write(d []byte) (int, error) { return len(d), nil } func (e *tstMtsEncoder) Close() error { return nil } // tstFlvEncoder emulates the flv.Encoder to the extent of the dst field. // This will allow access to the dst to check that it has been set corrctly. -type tstFlvEncoder struct{ dst io.WriteCloser } +type tstFlvEncoder struct { + // dst is here soley to detect the type stored in the encoder. + // No data is written to dst. + dst io.WriteCloser +} func (e *tstFlvEncoder) Write(d []byte) (int, error) { return len(d), nil } func (e *tstFlvEncoder) Close() error { return nil } // dummyMultiWriter emulates the MultiWriter provided by std lib, so that we // can access the destinations. -type dummyMultiWriter struct{ dst []io.WriteCloser } +type dummyMultiWriter struct { + // dst is here soley to detect the types stored in the multiWriter. + // No data is written to dst. + dst []io.WriteCloser +} func (w *dummyMultiWriter) Write(d []byte) (int, error) { return len(d), nil } func (w *dummyMultiWriter) Close() error { return nil } @@ -259,7 +271,7 @@ func TestResetEncoderSenderSetup(t *testing.T) { } // Now check that this encoder has correct number of destinations (senders). - var ms io.Writer + var ms io.WriteCloser switch encoderType { case mtsEncoderStr: ms = e.(*tstMtsEncoder).dst