docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,131 @@
---
id: testing-faker-and-builders
title: Test Data — Faker, Object Mother, Builder
category: Coding
status: draft
source_trust_level: B
verification_status: conceptual
created_at: 2026-05-09
updated_at: 2026-05-09
tags: [testing, fixtures, faker, builder, vibe-coding]
tech_stack: { language: "TypeScript", applicable_to: ["Backend", "Web"] }
applied_in: []
aliases: [test data builder, factory, object mother, fixture]
---
# Test Data — Faker / Mother / Builder
> 테스트 fixture 는 (1) 빠르게 만들 수 있어야 하고, (2) **이 테스트가 진짜 신경 쓰는 필드만 명시** 되어야 한다. 나머지는 무관한 디폴트. Object Mother + Builder + Faker 결합이 표준.
## 📖 핵심 개념
- **Faker**: 랜덤 그럴듯한 데이터 (이름, 이메일, 날짜).
- **Object Mother**: 자주 쓰는 시나리오에 이름 (`anAdminUser()`, `aPaidOrder()`).
- **Builder**: fluent API 로 일부 필드만 override.
## 💻 코드 패턴
### Faker (faker-js)
```ts
import { faker } from '@faker-js/faker';
faker.seed(42); // 재현 가능
const u = {
id: faker.string.uuid(),
email: faker.internet.email(),
name: faker.person.fullName(),
signedUpAt: faker.date.past({ years: 1 }),
};
```
### Object Mother
```ts
// test/mothers/userMother.ts
export function anAdminUser(over: Partial<User> = {}): User {
return {
id: faker.string.uuid(),
email: faker.internet.email(),
role: 'admin',
verified: true,
...over,
};
}
export function anUnverifiedUser(over: Partial<User> = {}) {
return anAdminUser({ role: 'viewer', verified: false, ...over });
}
// 사용
test('admin can ban', () => {
const admin = anAdminUser();
expect(canBan(admin)).toBe(true);
});
test('unverified cannot post', () => {
const u = anUnverifiedUser();
expect(canPost(u)).toBe(false);
});
```
### Builder (fluent)
```ts
class UserBuilder {
private u: User = anAdminUser(); // mother base
withEmail(e: string) { this.u.email = e; return this; }
withRole(r: Role) { this.u.role = r; return this; }
unverified() { this.u.verified = false; return this; }
build() { return { ...this.u }; }
}
const u = new UserBuilder().withEmail('a@a.com').unverified().build();
```
### Test factory + DB
```ts
// test/factories/userFactory.ts
export async function createUser(over: Partial<User> = {}) {
const u = anAdminUser(over);
return await db.users.insert(u);
}
test('login with seeded user', async () => {
const u = await createUser({ email: 'login@test.com' });
// ...
});
```
### 명시적으로 신경 쓰는 필드만
```ts
// ❌ 모든 필드 직접
const u = { id: '1', email: 'a@a.com', name: 'A', role: 'admin', ... 20 fields };
// 어느 것이 이 test 와 관련 있는지 모름
// ✅ 신경 쓰는 것만
const u = anAdminUser({ email: 'login@test.com' });
// 이 test 는 email 만 신경 — 명확
```
## 🤔 의사결정 기준
| 상황 | 패턴 |
|---|---|
| 단순 객체, 1-2 field 다양 | mother + over object |
| 많은 필드 / 다양한 시나리오 | Builder |
| 랜덤 입력 (property test) | Faker + fast-check |
| DB seeding | Factory (DB insert 포함) |
| 복잡 그래프 (User → Posts → Comments) | nested factory or fishery 라이브러리 |
## ❌ 안티패턴
- **fixture 안에 모든 필드 명시**: 변경 시 모든 test 깨짐. mother 로 디폴트.
- **공유 mutable fixture**: test 가 mutate 하면 다른 test 영향. 항상 새 인스턴스.
- **Faker seed 안 고정**: 매 실행 다른 데이터 → flaky. 전역 seed 또는 deterministic 데이터.
- **글로벌 DB seed 의존**: test 순서 의존. 각 test 가 자기 데이터.
- **가짜 같지 않은 데이터** (`name: 'test'`, `email: 'a@a.com'`): edge case 안 잡힘.
- **거대 builder 체인** (10+ 메서드): 그냥 시나리오별 mother 가 더 명확.
## 🤖 LLM 활용 힌트
- 매 테스트 fixture: "이 테스트가 신경 쓰는 필드만 명시. 나머지는 mother default" 강제.
- Faker seed 고정 (top-level beforeAll).
## 🔗 관련 문서
- [[Testing_Test_Pyramid]]
- [[Testing_Snapshot_Patterns]]