package inspur

import "testing"

func TestParseIDLLog_UsesBMCSourceForEventLogs(t *testing.T) {
	content := []byte(`|2025-12-02T17:54:27+08:00|MEMORY|Assert|Warning|0C180401|CPU1_C4D0 Memory Device Disabled - Assert|`)

	events := ParseIDLLog(content)
	if len(events) != 1 {
		t.Fatalf("expected 1 event, got %d", len(events))
	}
	if events[0].Source != "BMC" {
		t.Fatalf("expected IDL events to use BMC source, got %#v", events[0])
	}
	if events[0].SensorName != "CPU1_C4D0" {
		t.Fatalf("expected extracted DIMM component ref, got %#v", events[0])
	}
}

func TestParseSyslog_UsesHostSourceAndProcessAsSensorName(t *testing.T) {
	content := []byte(`<13>2026-03-15T14:03:11+00:00 host123 systemd[1]: Started Example Service`)

	events := ParseSyslog(content, "syslog/info")
	if len(events) != 1 {
		t.Fatalf("expected 1 event, got %d", len(events))
	}
	if events[0].Source != "syslog" {
		t.Fatalf("expected syslog source, got %#v", events[0])
	}
	if events[0].SensorName != "systemd[1]" {
		t.Fatalf("expected process name in sensor/component slot, got %#v", events[0])
	}
}
