chore(netlink): debug log ip rule commands in netlink instead of routing package

This commit is contained in:
Quentin McGaw
2024-10-19 12:43:26 +00:00
parent 2388e0550b
commit 3dfb43e117
8 changed files with 100 additions and 181 deletions

View File

@@ -0,0 +1,50 @@
package netlink
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_ruleDbgMsg(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
add bool
rule Rule
dbgMsg string
}{
"default values": {
dbgMsg: "ip rule del pref 0",
},
"add rule": {
add: true,
rule: Rule{
Src: makeNetipPrefix(1),
Dst: makeNetipPrefix(2),
Table: 100,
Priority: 101,
},
dbgMsg: "ip rule add from 1.1.1.0/24 to 2.2.2.0/24 lookup 100 pref 101",
},
"del rule": {
rule: Rule{
Src: makeNetipPrefix(1),
Dst: makeNetipPrefix(2),
Table: 100,
Priority: 101,
},
dbgMsg: "ip rule del from 1.1.1.0/24 to 2.2.2.0/24 lookup 100 pref 101",
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()
dbgMsg := ruleDbgMsg(testCase.add, testCase.rule)
assert.Equal(t, testCase.dbgMsg, dbgMsg)
})
}
}