package config_test

import (
	"testing"

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

func TestLoadDefaults(t *testing.T) {
	t.Setenv("SUPERVISOR_PORT", "")
	t.Setenv("LITELLM_BASE_URL", "")
	t.Setenv("LITELLM_API_KEY", "")
	t.Setenv("SUPERVISOR_CONFIG_DIR", "")

	cfg, err := config.Load()
	require.NoError(t, err)
	assert.Equal(t, "3200", cfg.Port)
	assert.Equal(t, "http://iguana:4000", cfg.LiteLLMBaseURL)
	assert.Equal(t, "./config/supervisor", cfg.ConfigDir)
}

func TestLoadFromEnv(t *testing.T) {
	t.Setenv("SUPERVISOR_PORT", "4000")
	t.Setenv("LITELLM_BASE_URL", "http://localhost:4000")
	t.Setenv("LITELLM_API_KEY", "test-key")
	t.Setenv("SUPERVISOR_CONFIG_DIR", "/etc/supervisor")

	cfg, err := config.Load()
	require.NoError(t, err)
	assert.Equal(t, "4000", cfg.Port)
	assert.Equal(t, "http://localhost:4000", cfg.LiteLLMBaseURL)
	assert.Equal(t, "test-key", cfg.LiteLLMAPIKey)
	assert.Equal(t, "/etc/supervisor", cfg.ConfigDir)
}
