Files
josh 9bb4b09a04
CI / Lint + build + test (push) Has been cancelled
Initial commit: full Phases 1-6 implementation
Post-repair hardware validation pipeline for Proxmox cluster hosts.
Go orchestrator + in-image agent + mkosi live image + bundled dnsmasq
PXE + SQLite + HTMX/SSE UI + notify registry + janitor + full docs.
2026-04-17 21:32:10 -04:00

38 lines
903 B
Go

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)
}
}
}