Skip to content

Commit

Permalink
adding testing case for net device that has colon in its name
Browse files Browse the repository at this point in the history
Signed-off-by: 吴家榜 <14038@chinasws.com>
  • Loading branch information
吴家榜 committed Nov 22, 2021
1 parent d5c58a4 commit 38346fe
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions net_dev_test.go
Expand Up @@ -14,21 +14,24 @@
package procfs

import (
"fmt"
"testing"
)

func TestNetDevParseLine(t *testing.T) {
const rawLine = ` eth0: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16`

have, err := NetDev{}.parseLine(rawLine)
if err != nil {
t.Fatal(err)
tc := []string{"eth0", "eth0:1"}
for i := range tc {
rawLine := fmt.Sprintf(` %v: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16`, tc[i])
have, err := NetDev{}.parseLine(rawLine)
if err != nil {
t.Fatal(err)
}
want := NetDevLine{tc[i], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
if want != *have {
t.Errorf("want %v, have %v", want, have)
}
}

want := NetDevLine{"eth0", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
if want != *have {
t.Errorf("want %v, have %v", want, have)
}
}

func TestNetDev(t *testing.T) {
Expand Down

0 comments on commit 38346fe

Please sign in to comment.