package platform

import "testing"

func TestParseFanSpeeds(t *testing.T) {
	raw := "FAN1 | 2400.000 | RPM | ok\nFAN2 | 1800 RPM | ok | ok\nFAN3 | na | RPM | ns\n"
	got := parseFanSpeeds(raw)
	if len(got) != 2 {
		t.Fatalf("fans=%d want 2 (%v)", len(got), got)
	}
	if got[0].Name != "FAN1" || got[0].RPM != 2400 {
		t.Fatalf("fan0=%+v", got[0])
	}
	if got[1].Name != "FAN2" || got[1].RPM != 1800 {
		t.Fatalf("fan1=%+v", got[1])
	}
}

func TestFirstFanInputValue(t *testing.T) {
	feature := map[string]any{
		"fan1_input": 9200.0,
	}
	got, ok := firstFanInputValue(feature)
	if !ok || got != 9200 {
		t.Fatalf("got=%v ok=%v", got, ok)
	}
}
