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

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