Skip to content

Commit

Permalink
Merge 9fbe923 into e5f1bb9
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-tucker committed Feb 6, 2015
2 parents e5f1bb9 + 9fbe923 commit a03d560
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion daemon/bridge_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package daemon

import "testing"
import (
"bytes"
"net"
"testing"
)

func TestGetAvailableGwAddress(t *testing.T) {
addr, err := GetAvailableGwAddress("")
Expand Down Expand Up @@ -75,3 +79,31 @@ func TestDeletePeer(t *testing.T) {
t.Fatal("Port has not been deleted")
}
}

func TestGenerateRandomName(t *testing.T) {
results := make(map[string]bool)
for i := 0; i <= 100; i++ {
result, err := GenerateRandomName("foo", 12)
if err != nil {
t.Fatal(err)
}
if results[result] != false {
t.Fatal("generated name not unique")
}
results[result] = true
}
}

func TestGenerateMacAddress(t *testing.T) {
ip := net.ParseIP("1.1.1.1")
mac := generateMacAddr(ip)
if mac[0] != 0x02 {
t.Fatal("first byte should be 0x02")
}
if mac[1] != 0x42 {
t.Fatal("second byte should be 0x42")
}
if !bytes.Equal(mac[2:], ip.To4()) {
t.Fatal("remaning bytes should be ipv4 address")
}
}

0 comments on commit a03d560

Please sign in to comment.