mirror of
https://github.com/halfwaystudent/douyin-sparkflow.git
synced 2026-09-04 23:17:51 +08:00
fix: isolate CI tests from runtime user data
This commit is contained in:
@@ -20,8 +20,6 @@ from utils.config import get_config, get_userData, normalize_unique_id, save_use
|
||||
from utils.logger import setup_logger
|
||||
|
||||
|
||||
config = get_config()
|
||||
user_data = get_userData()
|
||||
logger = setup_logger(level=logging.DEBUG)
|
||||
debug_artifacts_dir = Path("logs/debug_artifacts")
|
||||
debug_artifacts_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
@@ -27,6 +29,21 @@ class ConfigContractTests(unittest.TestCase):
|
||||
self.assertFalse(loaded["useProtocolSender"])
|
||||
self.assertTrue(loaded["persistentBrowserProfiles"]["enabled"])
|
||||
|
||||
def test_tasks_import_does_not_require_runtime_user_data(self):
|
||||
source_root = Path(__file__).resolve().parents[1]
|
||||
env = os.environ.copy()
|
||||
env["GITHUB_ACTIONS"] = "true"
|
||||
env.pop("USER_DATA", None)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", "import core.tasks"],
|
||||
cwd=source_root,
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
)
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
|
||||
def test_profile_root_environment_override_wins(self):
|
||||
with patch.dict(os.environ, {"SPARKFLOW_BROWSER_PROFILE_ROOT": "/tmp/sparkflow-profiles"}):
|
||||
normalized = tasks._normalize_persistent_profile_config(config_module.DEFAULT_CONFIG)
|
||||
|
||||
@@ -15,6 +15,7 @@ class DeploymentContractTests(unittest.TestCase):
|
||||
self.assertIn("working-directory: DouYinSparkFlow", text)
|
||||
self.assertIn("SPARKFLOW_BROWSER_PROFILE_ROOT", text)
|
||||
self.assertIn("SPARKFLOW_MANUAL_RUN", text)
|
||||
self.assertIn('USER_DATA: "[]"', text)
|
||||
self.assertIn("path: DouYinSparkFlow/logs/", text)
|
||||
|
||||
def test_github_actions_are_pinned_to_commit_shas(self):
|
||||
|
||||
Reference in New Issue
Block a user