diff --git a/stream/mts/meta/meta_test.go b/stream/mts/meta/meta_test.go index afd38544..6d98fe0f 100644 --- a/stream/mts/meta/meta_test.go +++ b/stream/mts/meta/meta_test.go @@ -29,9 +29,9 @@ package meta import ( "bytes" + "encoding/binary" "reflect" "testing" - "encoding/binary" ) const ( @@ -42,12 +42,6 @@ const ( tstData3 = "d,e,f" ) -var ( - errNotExpectedOut = "Did not get expected out. \nGot : %v, \nwant: %v\n" - errUnexpectedErr = "Unexpected err: %v\n" - errNotExpectedErr = "Not expected err: %v\n" -) - // TestAddAndGet ensures that we can add metadata and then successfully get it. func TestAddAndGet(t *testing.T) { meta := New() @@ -76,7 +70,7 @@ func TestUpdate(t *testing.T) { meta.Add(tstKey1, tstData3) if data, err := meta.Get(tstKey1); err != nil { - t.Errorf(errUnexpectedErr, err.Error()) + t.Errorf("Unexpected err: %v\n", err.Error()) if data != tstData2 { t.Errorf("Data did not correctly update for key \"loc\"") } @@ -106,7 +100,7 @@ func TestGetAbsentKey(t *testing.T) { meta := New() if _, err := meta.Get(tstKey1); err != errKeyAbsent { - t.Errorf(errNotExpectedErr, errKeyAbsent.Error()) + t.Errorf("Not expected err: %v\n", errKeyAbsent.Error()) } } @@ -115,10 +109,10 @@ func TestDelete(t *testing.T) { meta := New() meta.Add(tstKey1, tstData1) if err := meta.Delete(tstKey1); err != nil { - t.Errorf(errUnexpectedErr, err.Error()) + t.Errorf("Unexpected err: %v\n", err.Error()) } if _, err := meta.Get(tstKey1); err != errKeyAbsent { - t.Errorf(errNotExpectedErr, errKeyAbsent.Error()) + t.Errorf("Not expected err: %v\n", errKeyAbsent.Error()) } } @@ -127,7 +121,7 @@ func TestDelete(t *testing.T) { func TestDeleteAbsentKey(t *testing.T) { meta := New() if err := meta.Delete(tstKey1); err != errKeyAbsent { - t.Errorf(errNotExpectedErr, errKeyAbsent.Error()) + t.Errorf("Not expected err: %v\n", errKeyAbsent.Error()) } } @@ -142,14 +136,14 @@ func TestEncode(t *testing.T) { 0x00, 0x10, } - binary.BigEndian.PutUint16(header[2:4],uint16(dataLen)) + binary.BigEndian.PutUint16(header[2:4], uint16(dataLen)) expectedOut := append(header[:], []byte( tstKey1+"="+tstData1+"\t"+ tstKey2+"="+tstData2)...) got := meta.Encode() if !bytes.Equal(expectedOut, got) { - t.Errorf(errNotExpectedOut, got, expectedOut) + t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, expectedOut) } } @@ -157,18 +151,18 @@ func TestReadFrom(t *testing.T) { tstMeta := append([]byte{0x00, 0x10, 0x00, 0x12}, "loc=a,b,c\tts=12345"...) got, err := ReadFrom([]byte(tstMeta), "loc") if err != nil { - t.Errorf(errUnexpectedErr, err.Error()) + t.Errorf("Unexpected err: %v\n", err.Error()) } want := "a,b,c" if got != want { - t.Errorf(errNotExpectedOut, got, want) + t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, want) } if got, err = ReadFrom([]byte(tstMeta), "ts"); err != nil { - t.Errorf(errUnexpectedErr, err.Error()) + t.Errorf("Unexpected err: %v\n", err.Error()) } want = "12345" if got != want { - t.Errorf(errNotExpectedOut, got, want) + t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, want) } }