autool-dispatcher/test_minio_config.py
2026-06-17 19:50:39 +08:00

49 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""测试 Minio 配置是否生效"""
import sys
import os
# 确保从当前目录加载
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from config import MINIO_ENABLED, APK_DOWNLOAD_MODE
print("=" * 60)
print("Minio 配置测试")
print("=" * 60)
print(f"\nMINIO_ENABLED: {MINIO_ENABLED}")
print(f"APK_DOWNLOAD_MODE: {APK_DOWNLOAD_MODE}")
if MINIO_ENABLED:
print("\n❌ 配置未生效Minio 仍然启用")
print(" 请检查 config/prod.json 中的 MINIO_ENABLED 设置")
sys.exit(1)
else:
print("\n✓ 配置已生效Minio 已禁用")
# 测试 MinioStorage.create() 工厂方法
print("\n测试 MinioStorage.create() 工厂方法...")
try:
from apk_cloud.storage import MinioStorage
storage = MinioStorage.create()
if storage is None:
print("✓ MinioStorage.create() 返回 None符合预期")
else:
print(f"❌ MinioStorage.create() 返回了实例:{storage}")
sys.exit(1)
except ImportError as e:
print(f"⚠️ 无法导入 MinioStorage可能缺少 minio 依赖):{e}")
print(" 这是正常的,因为 Minio 未启用时不需要安装 minio 库")
except Exception as e:
print(f"❌ 测试失败:{e}")
sys.exit(1)
print("\n" + "=" * 60)
print("✓ 所有测试通过")
print("=" * 60)