package config_test

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

	"github.com/mathiasbq/supervisor/internal/config"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestModelsResolve(t *testing.T) {
	yaml := `
default: ollama/default-model
skills:
  tdd: ollama/qwen3-coder-30b-tuned
  review: ollama/devstral-tuned
`
	f := filepath.Join(t.TempDir(), "models.yaml")
	require.NoError(t, os.WriteFile(f, []byte(yaml), 0644))

	m, err := config.LoadModels(f)
	require.NoError(t, err)

	assert.Equal(t, "ollama/qwen3-coder-30b-tuned", m.Resolve("tdd", ""))
	assert.Equal(t, "ollama/devstral-tuned", m.Resolve("review", ""))
	assert.Equal(t, "ollama/default-model", m.Resolve("unknown", ""))
}

func TestModelsOverride(t *testing.T) {
	yaml := `
default: ollama/default-model
skills:
  tdd: ollama/qwen3-coder-30b-tuned
`
	f := filepath.Join(t.TempDir(), "models.yaml")
	require.NoError(t, os.WriteFile(f, []byte(yaml), 0644))

	m, err := config.LoadModels(f)
	require.NoError(t, err)

	assert.Equal(t, "anthropic/claude-sonnet-4-6", m.Resolve("tdd", "anthropic/claude-sonnet-4-6"))
}
