aboutsummaryrefslogtreecommitdiff
path: root/pkg/ipstack/ipstack_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ipstack/ipstack_test.go')
-rw-r--r--pkg/ipstack/ipstack_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkg/ipstack/ipstack_test.go b/pkg/ipstack/ipstack_test.go
index d5b755a..97c4947 100644
--- a/pkg/ipstack/ipstack_test.go
+++ b/pkg/ipstack/ipstack_test.go
@@ -53,3 +53,48 @@ func TestInterfaceUpThenDown(t *testing.T) {
fmt.Println("TestInterfaceUpThenDown successful")
t.Cleanup(func() { CleanUp() })
}
+
+func TestInterfaceUpThenDownTwice(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")
+ }
+
+ InterfaceUp(iface)
+ if iface.State == false {
+ t.Error("iface state should be true")
+ }
+ time.Sleep(3 * 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("TestInterfaceUpThenDownTwice successful")
+ t.Cleanup(func() { CleanUp() })
+}