//go:build windows

package agent

import (
	"os/exec"
	"testing"
)

func TestConfigureRuntimeCommandHidesWindow(t *testing.T) {
	cmd := exec.Command("cmd.exe", "/c", "exit", "0")
	configureRuntimeCommand(cmd)

	if cmd.SysProcAttr == nil {
		t.Fatal("expected Windows process attributes")
	}
	if !cmd.SysProcAttr.HideWindow {
		t.Fatal("expected runtime window to be hidden")
	}
	if cmd.SysProcAttr.CreationFlags&createNoWindow == 0 {
		t.Fatalf("expected CREATE_NO_WINDOW flag, got %#x", cmd.SysProcAttr.CreationFlags)
	}
	if cmd.Cancel == nil {
		t.Fatal("expected process-tree cancellation hook")
	}
}

func TestConfigureWindowsNoWindowHidesHelperWindow(t *testing.T) {
	cmd := exec.Command("taskkill.exe", "/T", "/F", "/PID", "123")
	configureWindowsNoWindow(cmd)

	if cmd.SysProcAttr == nil {
		t.Fatal("expected Windows process attributes")
	}
	if !cmd.SysProcAttr.HideWindow {
		t.Fatal("expected helper window to be hidden")
	}
	if cmd.SysProcAttr.CreationFlags&createNoWindow == 0 {
		t.Fatalf("expected CREATE_NO_WINDOW flag, got %#x", cmd.SysProcAttr.CreationFlags)
	}
	if cmd.Cancel != nil {
		t.Fatal("expected helper command to retain default cancellation")
	}
}
