fix: 避免测试环境工作空间缓存污染

This commit is contained in:
que01 committed 2026-09-23 08:56:11 +08:00
1 parent aeb1605a2a
commit 40b8cd6431
1 file changed
+2 -1
+2 -1
View File
@@ -160,7 +160,7 @@ export class PublicWorkspaceController {
: null; : null;
if (brandSlug && !selected) throw new NotFoundException("品牌不存在"); if (brandSlug && !selected) throw new NotFoundException("品牌不存在");
const brandId = selected?.id ?? configuredId; const brandId = selected?.id ?? configuredId;
const cached = this.cache.get(brandId); const cached = process.env.NODE_ENV === "test" ? undefined : this.cache.get(brandId);
if (cached && cached.expiresAt > Date.now()) return cached.value; if (cached && cached.expiresAt > Date.now()) return cached.value;
const [ const [
brand, brand,
@@ -343,6 +343,7 @@ export class PublicWorkspaceController {
trustContent: trustContents, trustContent: trustContents,
inquiryForm, inquiryForm,
}; };
if (process.env.NODE_ENV !== "test")
this.cache.set(brandId, { expiresAt: Date.now() + 30_000, value: response }); this.cache.set(brandId, { expiresAt: Date.now() + 30_000, value: response });
return response; return response;
} }