fix: route production IM API correctly
Deploy im-webapp production / deploy (push) Successful in 42s
Deploy im-webapp production / deploy (push) Successful in 42s
This commit is contained in:
@@ -3,12 +3,16 @@ import unittest
|
||||
|
||||
|
||||
WORKFLOW = Path(__file__).resolve().parents[1] / ".gitea/workflows/deploy.yml"
|
||||
DOCKERFILE = Path(__file__).resolve().parents[1] / "Dockerfile"
|
||||
API_CLIENT = Path(__file__).resolve().parents[1] / "web/src/lib/api/client.ts"
|
||||
|
||||
|
||||
class DeployWorkflowContractTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.workflow = WORKFLOW.read_text(encoding="utf-8")
|
||||
cls.dockerfile = DOCKERFILE.read_text(encoding="utf-8")
|
||||
cls.api_client = API_CLIENT.read_text(encoding="utf-8")
|
||||
|
||||
def test_targets_pro_branch_and_single_runner(self):
|
||||
self.assertIn("push:", self.workflow)
|
||||
@@ -35,8 +39,21 @@ class DeployWorkflowContractTest(unittest.TestCase):
|
||||
self.assertNotIn("git.118im.com", self.workflow)
|
||||
|
||||
def test_uses_production_im_endpoint(self):
|
||||
self.assertIn('TINODE_API_BASE="https://im-api.yuexuan.shop/v1/im"', self.workflow)
|
||||
self.assertIn('TINODE_FILE_BASE="https://im-api.yuexuan.shop/v0/file"', self.workflow)
|
||||
|
||||
def test_build_exposes_configured_api_base_to_vite(self):
|
||||
self.assertIn("ARG TINODE_API_BASE=", self.dockerfile)
|
||||
self.assertIn("ENV VITE_TINODE_API_BASE=$TINODE_API_BASE", self.dockerfile)
|
||||
|
||||
def test_strips_accidentally_quoted_api_key_before_build(self):
|
||||
self.assertIn('TINODE_API_KEY="${TINODE_API_KEY#\\\'}"', self.workflow)
|
||||
self.assertIn('TINODE_API_KEY="${TINODE_API_KEY%\\\'}"', self.workflow)
|
||||
|
||||
def test_api_client_prefers_the_configured_production_origin(self):
|
||||
self.assertIn("import.meta.env.VITE_TINODE_API_BASE?.trim()", self.api_client)
|
||||
self.assertIn("CONFIGURED_API_BASE || endpoints?.api || DEFAULT_API_BASE", self.api_client)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user