diff options
Diffstat (limited to 'pkg/ipstack/ipstack_test.go')
-rw-r--r-- | pkg/ipstack/ipstack_test.go | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/pkg/ipstack/ipstack_test.go b/pkg/ipstack/ipstack_test.go index 5530b9d..d5b755a 100644 --- a/pkg/ipstack/ipstack_test.go +++ b/pkg/ipstack/ipstack_test.go @@ -3,6 +3,7 @@ package ipstack import ( "fmt" "testing" + "time" ) func TestInitialize(t *testing.T) { @@ -11,10 +12,44 @@ func TestInitialize(t *testing.T) { 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") - PrintInterfaces() - fmt.Println("Interfaces^^") - PrintNeighbors() - fmt.Println("Neighbors^^") - fmt.Println(SprintRoutingTable()) + 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() }) } |