From dc46d9f0b28e088454d79c17dc75bca0fe93cb58 Mon Sep 17 00:00:00 2001 From: saxon Date: Tue, 5 Feb 2019 23:18:05 +1030 Subject: [PATCH] stream/mts/encoder.go: not doing scoped conditional in writePSI when calling updateMeta --- stream/mts/encoder.go | 4 ++-- stream/mts/meta/meta_test.go | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 6a0c55d3..0e52cb70 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -216,8 +216,8 @@ func (e *Encoder) writePSI() error { if err != nil { return err } - - if err = updateMeta(&pmtTable); err != nil { + err = updateMeta(&pmtTable) + if err != nil { return err } diff --git a/stream/mts/meta/meta_test.go b/stream/mts/meta/meta_test.go index 15789ebf..afd38544 100644 --- a/stream/mts/meta/meta_test.go +++ b/stream/mts/meta/meta_test.go @@ -29,9 +29,9 @@ package meta import ( "bytes" - "errors" "reflect" "testing" + "encoding/binary" ) const ( @@ -53,7 +53,6 @@ func TestAddAndGet(t *testing.T) { meta := New() meta.Add(tstKey1, tstData1) meta.Add(tstKey2, tstData2) - errors.New("Trying to delete map entry that doesn't exist") if data, err := meta.Get(tstKey1); err != nil { t.Errorf("Could not get data for key: loc: %v", err.Error()) if data != tstData1 { @@ -139,13 +138,12 @@ func TestEncode(t *testing.T) { meta.Add(tstKey2, tstData2) dataLen := len(tstKey1+tstData1+tstKey2+tstData2) + 3 - expectedOut := []byte{ + header := [4]byte{ 0x00, 0x10, - byte(dataLen >> 8), - byte(dataLen), } - expectedOut = append(expectedOut, []byte( + binary.BigEndian.PutUint16(header[2:4],uint16(dataLen)) + expectedOut := append(header[:], []byte( tstKey1+"="+tstData1+"\t"+ tstKey2+"="+tstData2)...)