[#641] ir/container: Add unique attributes check

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-23 15:45:42 +03:00 committed by Alex Vanin
parent 75709deb6f
commit 6efeee5ce0
2 changed files with 46 additions and 1 deletions

View file

@ -41,4 +41,30 @@ func TestCheckFormat(t *testing.T) {
c.SetNonceUUID(uuid.New())
require.NoError(t, CheckFormat(c))
// set empty value attribute
attr1 := container.NewAttribute()
attr1.SetKey("attr")
attrs := container.Attributes{attr1}
c.SetAttributes(attrs)
require.ErrorIs(t, CheckFormat(c), errEmptyAttribute)
// add same key attribute
attr2 := container.NewAttribute()
attr2.SetKey(attr1.Key())
attr2.SetValue("val")
attr1.SetValue(attr2.Value())
attrs = append(attrs, attr2)
c.SetAttributes(attrs)
require.ErrorIs(t, CheckFormat(c), errRepeatedAttributes)
attr2.SetKey(attr1.Key() + "smth")
require.NoError(t, CheckFormat(c))
}