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.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user