bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/snmp/walk_test.go (about) 1 // +build ignore 2 3 package snmp 4 5 import ( 6 _ "fmt" 7 "testing" 8 _ "time" 9 ) 10 11 func TestWalk(t *testing.T) { 12 s, err := Walk("localhost", "public", "IF-MIB::ifDescr", "IF-MIB::ifMtu") 13 if err != nil { 14 t.Errorf("unexpected error: %v", err) 15 return 16 } 17 for s.Next() { 18 var a, b interface{} 19 _, err := s.Scan(&a, &b) 20 if err != nil { 21 t.Errorf("unexpected error: %v", err) 22 break 23 } 24 if a == nil || b == nil { 25 t.Errorf("unexpected nil") 26 break 27 } 28 if _, ok := a.([]byte); !ok { 29 t.Errorf("unexpected response: %T", a) 30 break 31 } 32 if _, ok := b.(int64); !ok { 33 t.Errorf("unexpected response: %T", b) 34 break 35 } 36 // t.Log(string(a.([]byte)), b) 37 } 38 if err := s.Err(); err != nil { 39 t.Errorf("unexpected error: %v", err) 40 return 41 } 42 }