package config

import (
	"testing"

	"crypto-miner-agent/stats"
)

func TestAdaptToSystemCapsThreadsByRAM(t *testing.T) {
	reporter := stats.NewReporter()
	cfg := RuntimeConfig{BuiltinConfig: BuiltinConfig{
		ThreadMode:     "fixed",
		Threads:        16,
		MaxMemoryPct:   50,
		AdaptToHardware: true,
		MinFreeRAM:     999999,
	}}

	// Without real Windows memory APIs in test env, AdaptToSystem may no-op on totalMB=0.
	adapted := cfg.AdaptToSystem(reporter)
	if adapted.Threads != cfg.Threads && reporter.TotalMemoryMB() == 0 {
		t.Fatalf("unexpected thread change without memory info: %d", adapted.Threads)
	}
}
