Skip to content

Commit

Permalink
morph: Adapt tests for new errors
Browse files Browse the repository at this point in the history
The object can't be a slice with only zeros.

Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Aug 12, 2024
1 parent b4c786e commit 7009a45
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pkg/services/audit/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,42 +263,42 @@ func TestResultUnmarshalingFailures(t *testing.T) {
}},
{name: "invalid passed SG/nil value", err: "invalid passed storage group #1: invalid length 0", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[2].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[2].SetValue(randomObjectID())
r.SetPassSG(ids)
}},
{name: "invalid passed SG/empty value", err: "invalid passed storage group #1: invalid length 0", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[1].SetValue([]byte{})
ids[2].SetValue(make([]byte, 32))
ids[2].SetValue(randomObjectID())
r.SetPassSG(ids)
}},
{name: "invalid passed SG/wrong length", err: "invalid passed storage group #1: invalid length 31", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[1].SetValue(make([]byte, 31))
ids[2].SetValue(make([]byte, 32))
ids[2].SetValue(randomObjectID())
r.SetPassSG(ids)
}},
{name: "invalid failed SG/nil value", err: "invalid failed storage group #1: invalid length 0", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[2].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[2].SetValue(randomObjectID())
r.SetFailSG(ids)
}},
{name: "invalid failed SG/empty value", err: "invalid failed storage group #1: invalid length 0", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[1].SetValue([]byte{})
ids[2].SetValue(make([]byte, 32))
ids[2].SetValue(randomObjectID())
r.SetFailSG(ids)
}},
{name: "invalid failed SG/wrong length", err: "invalid failed storage group #1: invalid length 31", corrupt: func(r *apiaudit.DataAuditResult) {
ids := make([]refs.ObjectID, 3)
ids[0].SetValue(make([]byte, 32))
ids[0].SetValue(randomObjectID())
ids[1].SetValue(make([]byte, 31))
ids[2].SetValue(make([]byte, 32))
ids[2].SetValue(randomObjectID())
r.SetFailSG(ids)
}},
} {
Expand All @@ -314,3 +314,8 @@ func TestResultUnmarshalingFailures(t *testing.T) {
}
})
}

func randomObjectID() []byte {
o := oidtest.ID()
return o[:]
}

0 comments on commit 7009a45

Please sign in to comment.