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)...)