forked from TrueCloudLab/frostfs-node
[#641] ir/container: Add unique attributes check
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
75709deb6f
commit
6efeee5ce0
2 changed files with 46 additions and 1 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue