mirror of https://bitbucket.org/ausocean/av.git
stream/mts/meta/meta_test.go: adding test for ReadFrom
This commit is contained in:
parent
1f1546a284
commit
38d5d6f0fd
|
@ -42,6 +42,10 @@ const (
|
|||
tstData3 = "d,e,f"
|
||||
)
|
||||
|
||||
var (
|
||||
errNotExpectedOut = "Did not get expected out. \nGot : %v, \nwant: %v"
|
||||
)
|
||||
|
||||
// TestAddAndGet ensures that we can add metadata and then successfully get it.
|
||||
func TestAddAndGet(t *testing.T) {
|
||||
meta := New()
|
||||
|
@ -145,6 +149,26 @@ func TestEncode(t *testing.T) {
|
|||
|
||||
got := meta.Encode()
|
||||
if !bytes.Equal(expectedOut, got) {
|
||||
t.Errorf("Did not get expected out. \nGot : %v \nwant: %v", got, expectedOut)
|
||||
t.Errorf(errNotExpectedOut, got, expectedOut)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFrom(t *testing.T) {
|
||||
tstStr := "loc=a,b,c\tts=12345"
|
||||
got, err := ReadFrom([]byte(tstStr), "loc")
|
||||
if err != nil {
|
||||
t.Errorf("Got unexpected error: %v", err.Error())
|
||||
}
|
||||
want := "a,b,c"
|
||||
if got != want {
|
||||
t.Errorf(errNotExpectedOut, got, want)
|
||||
}
|
||||
|
||||
if got, err = ReadFrom([]byte(tstStr), "ts"); err != nil {
|
||||
t.Errorf("Got unexpected error: %v", err.Error())
|
||||
}
|
||||
want = "12345"
|
||||
if got != want {
|
||||
t.Errorf(errNotExpectedOut, got, want)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue