//go:build windows

package dispatcher

import (
	"os"
	"path/filepath"
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/tidbcloud/AgentTeam/desktop/internal/profile"
)

func TestEnsureSessionWorkDirDurableUsesWindowsDirectorySemantics(t *testing.T) {
	configDir := t.TempDir()
	t.Setenv(profile.ConfigDirEnvKey, configDir)
	workDir := filepath.Join(configDir, "agents", "windows-agent")

	d := mustNewDispatcher("http://server.test")
	require.NoError(t, d.ensureSessionWorkDirDurable(workDir))
	require.DirExists(t, workDir)

	file := filepath.Join(configDir, "not-a-directory")
	require.NoError(t, os.WriteFile(file, []byte("x"), 0o600))
	require.Error(t, syncSessionResumeStateDir(file))
}
