diff --git a/container/mts/meta/meta_test.go b/container/mts/meta/meta_test.go index 9316ce55..87c52461 100644 --- a/container/mts/meta/meta_test.go +++ b/container/mts/meta/meta_test.go @@ -219,3 +219,35 @@ func TestKeys(t *testing.T) { t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v\n", got, want) } } + +// TestNewFromMap checks that we can successfully create a new data struct from a map. +func TestNewFromMap(t *testing.T) { + want := map[string]string{ + "loc": "a,b,c", + "ts": "12345", + } + + meta := NewFromMap(want) + + got := meta.All() + + if !reflect.DeepEqual(got, want) { + t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v\n", got, want) + } +} + +// TestEncodeAsString checks that metadata is correctly encoded as a string. +func TestEncodeAsString(t *testing.T) { + meta := NewFromMap(map[string]string{ + "loc": "a,b,c", + "ts": "12345", + }) + + got := meta.EncodeAsString() + want1 := "loc=a,b,c\tts=12345" + want2 := "ts=12345\tloc=a,b,c" + + if got != want1 && got != want2 { + t.Errorf("Did not get expected out. \nGot : %v, \nWant: %v or %v\n", got, want1, want2) + } +}