fix: enable empty and len rules from testifylint on pkg package

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
Matthieu MOREL
2024-06-28 21:20:13 +02:00
parent 40225a788c
commit f014b754fb
54 changed files with 203 additions and 207 deletions

View File

@@ -158,7 +158,7 @@ func TestRunner_Add(t *testing.T) {
}
// validate number of requests
assert.Equal(t, tc.netlinkCalls, len(tc.handler.requests))
assert.Len(t, tc.handler.requests, tc.netlinkCalls)
if tc.netlinkCalls > 0 {
// validate request
@@ -166,7 +166,7 @@ func TestRunner_Add(t *testing.T) {
assert.Equal(t, uint16(unix.NLM_F_REQUEST|unix.NLM_F_CREATE|unix.NLM_F_ACK), tc.handler.requests[0].flags)
// validate attribute(NFACCT_NAME)
assert.Equal(t, 1, len(tc.handler.requests[0].data))
assert.Len(t, tc.handler.requests[0].data, 1)
assert.Equal(t,
tc.handler.requests[0].data[0].Serialize(),
nl.NewRtAttr(attrName, nl.ZeroTerminated(tc.counterName)).Serialize(),
@@ -343,14 +343,14 @@ func TestRunner_Get(t *testing.T) {
counter, err := rnr.Get(tc.counterName)
// validate number of requests
assert.Equal(t, tc.netlinkCalls, len(tc.handler.requests))
assert.Len(t, tc.handler.requests, tc.netlinkCalls)
if tc.netlinkCalls > 0 {
// validate request
assert.Equal(t, cmdGet, tc.handler.requests[0].cmd)
assert.Equal(t, uint16(unix.NLM_F_REQUEST|unix.NLM_F_ACK), tc.handler.requests[0].flags)
// validate attribute(NFACCT_NAME)
assert.Equal(t, 1, len(tc.handler.requests[0].data))
assert.Len(t, tc.handler.requests[0].data, 1)
assert.Equal(t,
tc.handler.requests[0].data[0].Serialize(),
nl.NewRtAttr(attrName, nl.ZeroTerminated(tc.counterName)).Serialize())
@@ -417,7 +417,7 @@ func TestRunner_Ensure(t *testing.T) {
assert.NoError(t, err)
// validate number of netlink requests
assert.Equal(t, tc.netlinkCalls, len(tc.handler.requests))
assert.Len(t, tc.handler.requests, tc.netlinkCalls)
})
}
@@ -481,12 +481,12 @@ func TestRunner_List(t *testing.T) {
counters, err := rnr.List()
// validate request(NFNL_MSG_ACCT_GET)
assert.Equal(t, 1, len(hndlr.requests))
assert.Len(t, hndlr.requests, 1)
assert.Equal(t, cmdGet, hndlr.requests[0].cmd)
assert.Equal(t, uint16(unix.NLM_F_REQUEST|unix.NLM_F_DUMP), hndlr.requests[0].flags)
// validate attributes
assert.Equal(t, 0, len(hndlr.requests[0].data))
assert.Empty(t, hndlr.requests[0].data)
// validate response
assert.NoError(t, err)