package orchestrator import ( "bytes" "testing" ) func TestParseMAC(t *testing.T) { got, err := parseMAC("aa:bb:cc:dd:ee:ff") if err != nil { t.Fatalf("parseMAC: %v", err) } want := []byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff} if !bytes.Equal(got, want) { t.Fatalf("parseMAC: %x != %x", got, want) } } func TestParseMACUpper(t *testing.T) { // Must be case-insensitive so users can paste either form. got, err := parseMAC("AA:BB:CC:DD:EE:FF") if err != nil { t.Fatalf("parseMAC upper: %v", err) } want := []byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff} if !bytes.Equal(got, want) { t.Fatalf("parseMAC upper: %x != %x", got, want) } } func TestParseMACInvalid(t *testing.T) { for _, bad := range []string{"", "aa:bb:cc", "zz:yy:xx:ww:vv:uu", "aa-bb-cc-dd-ee-ff", "aa:bb:cc:dd:ee:ff:00"} { if _, err := parseMAC(bad); err == nil { t.Errorf("expected error for %q", bad) } } }