Refactor Store Management to Replace Badger with Xun

- Removed references to Badger in the `utils.go` and `utils_test.go` files, replacing it with Xun as the primary data store.
- Updated test cases and comments to reflect the change in store preference, ensuring consistency across the codebase.
- Adjusted the testing guide to provide accurate information regarding store management and fallback options.
This commit is contained in:
Max 2025-12-22 09:27:32 +08:00
parent a966ad83ee
commit e275116022
4 changed files with 8 additions and 13 deletions

View file

@ -111,7 +111,7 @@ func DetectType(path string) Type {
return TypeModel return TypeModel
case "conn": case "conn":
return TypeConnector return TypeConnector
case "lru", "redis", "mongo", "badger": case "lru", "redis", "mongo", "xun":
return TypeStore return TypeStore
} }
@ -187,7 +187,7 @@ func TypeRootAndExts(typ Type) (string, []string) {
case TypeAIGC: case TypeAIGC:
return "aigcs", []string{".ai.yao", ".ai.jsonc", ".ai.json"} return "aigcs", []string{".ai.yao", ".ai.jsonc", ".ai.json"}
case TypeStore: case TypeStore:
return "stores", []string{".lru.yao", ".redis.yao", ".mongo.yao", ".badger.yao", ".store.yao", ".store.jsonc", ".store.json"} return "stores", []string{".lru.yao", ".redis.yao", ".mongo.yao", ".xun.yao", ".store.yao", ".store.jsonc", ".store.json"}
default: default:
return "", []string{} return "", []string{}
} }

View file

@ -257,11 +257,6 @@ func TestDetectType(t *testing.T) {
path: filepath.Join("stores", "cache.mongo.yao"), path: filepath.Join("stores", "cache.mongo.yao"),
want: TypeStore, want: TypeStore,
}, },
{
name: "Store Badger",
path: filepath.Join("stores", "cache.badger.yao"),
want: TypeStore,
},
{ {
name: "Store by extension", name: "Store by extension",
path: filepath.Join("stores", "cache.store.yao"), path: filepath.Join("stores", "cache.store.yao"),
@ -510,7 +505,7 @@ func TestTypeRootAndExts(t *testing.T) {
name: "Store", name: "Store",
typ: TypeStore, typ: TypeStore,
wantRoot: "stores", wantRoot: "stores",
wantExts: []string{".lru.yao", ".redis.yao", ".mongo.yao", ".badger.yao", ".store.yao", ".store.jsonc", ".store.json"}, wantExts: []string{".lru.yao", ".redis.yao", ".mongo.yao", ".xun.yao", ".store.yao", ".store.jsonc", ".store.json"},
}, },
{ {
name: "Unknown", name: "Unknown",

View file

@ -9,7 +9,7 @@ This guide provides comprehensive testing infrastructure for OAuth 2.1 authoriza
### Core Components ### Core Components
- **OAuth Service Configuration**: Complete OAuth 2.1 configuration with all features enabled - **OAuth Service Configuration**: Complete OAuth 2.1 configuration with all features enabled
- **Store Management**: Support for MongoDB and Badger stores with automatic fallback - **Store Management**: Support for MongoDB and Xun (database-backed) stores with automatic fallback
- **Test Data Sets**: Pre-configured clients and users for comprehensive testing - **Test Data Sets**: Pre-configured clients and users for comprehensive testing
- **Environment Setup**: Standardized initialization and cleanup procedures - **Environment Setup**: Standardized initialization and cleanup procedures
@ -110,7 +110,7 @@ source $YAO_SOURCE_ROOT/env.local.sh
func setupOAuthTestEnvironment(t *testing.T) (*Service, store.Store, store.Store, func()) { func setupOAuthTestEnvironment(t *testing.T) (*Service, store.Store, store.Store, func()) {
// Creates complete OAuth test environment with: // Creates complete OAuth test environment with:
// - Configured OAuth service with all features enabled // - Configured OAuth service with all features enabled
// - Primary store (MongoDB preferred, Badger fallback) // - Primary store (MongoDB preferred, Xun database fallback)
// - Cache store (LRU cache) // - Cache store (LRU cache)
// - Pre-loaded test clients and users // - Pre-loaded test clients and users
// - Cleanup function for proper teardown // - Cleanup function for proper teardown
@ -325,7 +325,7 @@ export MONGO_TEST_PASS=test
### Common Issues ### Common Issues
1. **Store Connection**: Check MongoDB availability or use Badger fallback 1. **Store Connection**: Check MongoDB availability or use Xun (database) fallback
2. **Environment Setup**: Ensure `env.local.sh` is sourced 2. **Environment Setup**: Ensure `env.local.sh` is sourced
3. **Test Timeouts**: Increase timeout for slow operations 3. **Test Timeouts**: Increase timeout for slow operations
4. **Data Conflicts**: ✅ **RESOLVED** - Now automatically handled with unique test suffixes 4. **Data Conflicts**: ✅ **RESOLVED** - Now automatically handled with unique test suffixes
@ -361,7 +361,7 @@ Tests include comprehensive logging:
### Performance Considerations ### Performance Considerations
- **MongoDB**: Preferred for full feature testing - **MongoDB**: Preferred for full feature testing
- **Badger**: Fast fallback for basic testing - **Xun**: Database-backed fallback with LRU cache layer
- **Cache**: LRU cache for improved performance - **Cache**: LRU cache for improved performance
- **Cleanup**: Efficient cleanup procedures - **Cleanup**: Efficient cleanup procedures

View file

@ -331,7 +331,7 @@ func setupOAuthTestEnvironment(t *testing.T) (*Service, store.Store, store.Store
// Get store configurations // Get store configurations
storeConfigs := getStoreConfigs() storeConfigs := getStoreConfigs()
// Use the first available store (prefer MongoDB, fallback to Badger) // Use the first available store (prefer MongoDB, fallback to Xun)
var mainStore store.Store var mainStore store.Store
var storeConfig StoreConfig var storeConfig StoreConfig