package ipstack import ( "fmt" "testing" "time" ) func TestInitialize(t *testing.T) { lnxFilePath := "../../doc-example/r2.lnx" err := Initialize(lnxFilePath) if err != nil { t.Error(err) } fmt.Printf("Interfaces:\n%s\n\n", SprintInterfaces()) fmt.Printf("Neighbors:\n%s\n", SprintNeighbors()) fmt.Printf("RoutingTable:\n%s\n", SprintRoutingTable()) fmt.Println("TestInitialize successful") t.Cleanup(func() { CleanUp() }) } func TestInterfaceUpThenDown(t *testing.T) { lnxFilePath := "../../doc-example/r2.lnx" err := Initialize(lnxFilePath) if err != nil { t.Error(err) } iface, err := GetInterfaceByName("if0") if err != nil { t.Error(err) } InterfaceUp(iface) if iface.State == false { t.Error("iface state should be true") } fmt.Printf("Interfaces:\n%s\n", SprintInterfaces()) time.Sleep(5 * time.Millisecond) // allow time to print InterfaceDown(iface) if iface.State == true { t.Error("iface state should be false") } time.Sleep(5 * time.Millisecond) // allow time to print fmt.Printf("Interfaces:\n%s\n", SprintInterfaces()) fmt.Println("TestInterfaceUpThenDown successful") t.Cleanup(func() { CleanUp() }) }