package server

import (
	"testing"

	"github.com/gin-gonic/gin"
	"github.com/stretchr/testify/assert"
)

// TestResolveGinMode 测试 Gin 模式解析
func TestResolveGinMode(t *testing.T) {
	tests := []struct {
		name     string
		mode     string
		expected string
	}{
		{"debug", "debug", gin.DebugMode},
		{"test", "test", gin.TestMode},
		{"release", "release", gin.ReleaseMode},
		{"empty", "", gin.ReleaseMode},
		{"invalid", "invalid", gin.ReleaseMode},
		{"other", "other", gin.ReleaseMode},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got := resolveGinMode(tt.mode)
			assert.Equal(t, tt.expected, got)
		})
	}
}

// TestResolveGinMode_CaseSensitivity 测试大小写敏感性
func TestResolveGinMode_CaseSensitivity(t *testing.T) {
	// 函数是区分大小写的
	assert.Equal(t, gin.DebugMode, resolveGinMode("debug"))
	assert.Equal(t, gin.ReleaseMode, resolveGinMode("DEBUG")) // 大写不匹配
	assert.Equal(t, gin.ReleaseMode, resolveGinMode("Debug")) // 首字母大写不匹配
}
