bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/scollector/collectors/metadata_linux_test.go (about)

     1  package collectors
     2  
     3  import "testing"
     4  
     5  func TestLinuxIpAddrShowMaster(t *testing.T) {
     6  	inputs := map[string]string{
     7  		"bond0": `2: em1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000\    link/ether bc:30:5b:ed:c0:80 brd ff:ff:ff:ff:ff:ff`,
     8  		"bond1": `5: em4: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP qlen 1000\    link/ether bc:30:5b:ed:c0:3a brd ff:ff:ff:ff:ff:ff`,
     9  		"":      `7: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP \    link/ether bc:30:5b:ed:c0:3a brd ff:ff:ff:ff:ff:ff`,
    10  	}
    11  	for expect, val := range inputs {
    12  		got := metaLinuxIfacesMaster(val)
    13  		if got != expect {
    14  			t.Errorf("%v: expected %v, got %v", val, expect, got)
    15  		}
    16  	}
    17  }