♻️ Get rid of PartialEntry

This commit is contained in:
Dan Jones 2024-03-10 15:26:00 -05:00
commit 820a2de269
5 changed files with 111 additions and 57 deletions

View file

@ -97,3 +97,31 @@ func getMetaTestRunner(key string, value any, out string, err error, newVal any)
}
}
}
func TestMetasJson(t *testing.T) {
ms := Metas{{"me", 41}, {"you", false}}
exp := `{"me":41,"you":false}`
o, err := json.Marshal(ms)
assert.NoError(t, err)
assert.JSONEq(t, exp, string(o))
}
func TestMetasJsonUnmarshal(t *testing.T) {
ms := Metas{}
in := `{"me":"cool","you":false}`
err := json.Unmarshal([]byte(in), &ms)
assert.NoError(t, err)
assert.Len(t, ms, 2)
assert.ElementsMatch(t, Metas{
{"me", "cool"},
{"you", false},
}, ms)
}
func TestMetasJsonError(t *testing.T) {
ms := Metas{}
in := "not json"
err := (&ms).UnmarshalJSON([]byte(in))
assert.Error(t, err)
assert.Len(t, ms, 0)
}