yao/openapi/tests/user/config_functions_test.go
Max 9044d4c30a Enhance user login and team configuration management
- Updated login configuration tests to clarify endpoint descriptions.
- Introduced team configuration loading and retrieval functionality, including new endpoints for public access to team configurations.
- Refactored team management routes to standardize parameter usage and improve clarity.
- Added error handling for missing environment variables in client configuration.
- Implemented team configuration types and related structures for better organization and usability.
2025-10-07 10:23:43 +08:00

59 lines
2.1 KiB
Go

package user_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/yao/openapi/user"
)
// TestGetTeamConfigFunction tests the GetTeamConfig function
func TestGetTeamConfigFunction(t *testing.T) {
// Test with empty locale
teamConfig := user.GetTeamConfig("")
assert.Nil(t, teamConfig, "Should return nil when no config is loaded")
// Test with specific locale
teamConfig = user.GetTeamConfig("en")
assert.Nil(t, teamConfig, "Should return nil when no config is loaded")
// Test with invalid locale
teamConfig = user.GetTeamConfig("invalid")
assert.Nil(t, teamConfig, "Should return nil when no config is loaded")
}
// TestGetPublicConfigFunction tests the GetPublicConfig function
func TestGetPublicConfigFunction(t *testing.T) {
// Test with empty locale
publicConfig := user.GetPublicConfig("")
assert.Nil(t, publicConfig, "Should return nil when no config is loaded")
// Test with specific locale
publicConfig = user.GetPublicConfig("en")
assert.Nil(t, publicConfig, "Should return nil when no config is loaded")
// Test with invalid locale
publicConfig = user.GetPublicConfig("invalid")
assert.Nil(t, publicConfig, "Should return nil when no config is loaded")
}
// TestGetYaoClientConfigFunction tests the GetYaoClientConfig function
func TestGetYaoClientConfigFunction(t *testing.T) {
// Test when no client config is loaded
clientConfig := user.GetYaoClientConfig()
assert.Nil(t, clientConfig, "Should return nil when no client config is loaded")
}
// TestGetProviderFunction tests the GetProvider function
func TestGetProviderFunction(t *testing.T) {
// Test with non-existent provider
provider, err := user.GetProvider("non-existent")
assert.Error(t, err, "Should return error for non-existent provider")
assert.Nil(t, provider, "Should return nil provider for non-existent provider")
assert.Contains(t, err.Error(), "not found", "Error should contain 'not found'")
// Test with empty provider ID
provider, err = user.GetProvider("")
assert.Error(t, err, "Should return error for empty provider ID")
assert.Nil(t, provider, "Should return nil provider for empty provider ID")
}