package server

import (
	"testing"

	"git.mchus.pro/mchus/logpile/internal/models"
)

func TestBuildParserFieldSummary_MirrorsBoardInfoToTopLevel(t *testing.T) {
	result := &models.AnalysisResult{
		Hardware: &models.HardwareConfig{
			BoardInfo: models.BoardInfo{
				Manufacturer: "Supermicro",
				ProductName:  "SYS-821GE-TNHR",
				SerialNumber: "A514359X5C08846",
				PartNumber:   "SYS-821GE-TNHR",
			},
		},
	}

	got := buildParserFieldSummary(result)

	if got["vendor"] != "Supermicro" {
		t.Fatalf("expected vendor mirror, got %v", got["vendor"])
	}
	if got["model"] != "SYS-821GE-TNHR" {
		t.Fatalf("expected model mirror, got %v", got["model"])
	}
	if got["serial"] != "A514359X5C08846" {
		t.Fatalf("expected serial mirror, got %v", got["serial"])
	}
	if got["part_number"] != "SYS-821GE-TNHR" {
		t.Fatalf("expected part_number mirror, got %v", got["part_number"])
	}
}
