package inspur import ( "testing" "time" "git.mchus.pro/mchus/logpile/internal/parser" ) func TestParseCommerCompEvents(t *testing.T) { content := []byte(`[2026-07-08 16:46:19][commer_comp_anal.c, 635][Critial] [COMP]Invalid Comp Data, Continue... ParamList: Index-3, Valid-0x1, MediaType-0(1-PCIE,2-I2C) [2026-07-27 04:52:55][commer_comp_slot.c, 319][Critial] Data Update fail for dev serial-6! [2026-07-27 04:52:55][commer_comp_slot.c, 319][Critial] Data Update fail for dev serial-7! [2026-07-27 05:00:00][commer_comp_slot.c, 100][Info] Error in update redis, retry `) files := []parser.ExtractedFile{ {Path: "log/bmc/commer-comp/commerslot/commerslot.log", Content: content}, } events := ParseCommerCompEvents(files, time.UTC) if len(events) != 2 { t.Fatalf("expected 2 events (noise filtered), got %d: %+v", len(events), events) } for _, e := range events { if e.Source != "BMC/commerslot" { t.Fatalf("unexpected source %q", e.Source) } } if events[0].Timestamp.Format("2006-01-02 15:04:05") != "2026-07-27 04:52:55" { t.Fatalf("unexpected timestamp: %v", events[0].Timestamp) } if events[0].ID == events[1].ID { t.Fatalf("expected distinct event IDs for serial-6/serial-7, got same: %q", events[0].ID) } }