Files
roblox-project/bunsik-tycoon/tests/Receipts.spec.luau
EJClaw 802ba10e1a feat(bunsik): MVP 전체 구현 — 맵, 요리·서빙, 손님 NPC, 업그레이드 20개, 세이브, 결제, 한/영 UI
- Shop.luau: 손님·주문·조리·서빙·구매 순수 로직(lune 단위 테스트, 시뮬레이터 공용)
- 서버: World(부지 6칸), PlotBuilder(파트 모형), PlotController, Npc(트윈 이동), Data(ProfileStore), Receipts(결제 1회 = 지급 1회), Game
- 클라이언트: Hud(돈·다음 업그레이드·목록·결제·언어·튜토리얼), 내 조리대 전용 버튼, 튜토리얼 화살표, 주인 전용 테스트 버튼
- 2단계 업그레이드 10개 추가, 파이썬 시뮬레이터를 실제 로직 기반 tools/sim.luau로 교체
- tools/cloud.py: 업로드, 원격 Luau 실행, 게임패스·개발자 상품 생성, 서버 인원 설정
- tests/cloud/integration.luau: 로블록스 서버 통합 테스트 514개 통과
- check.sh에 luau-lsp 타입 검사 추가, ProfileStore 고정 버전 포함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 01:34:06 +09:00

91 lines
2.3 KiB
Lua

-- 결제 1회 = 지급 1회 검사(가짜 프로필): lune run tests/Receipts.spec.luau
local Receipts = require("../src/server/Receipts")
local T = require("./check")
local function deepcopy(t)
local out = {}
for k, v in t do
out[k] = if type(v) == "table" then deepcopy(v) else v
end
return out
end
local function fakeProfile(saveWorks: boolean)
local p = {
Data = { PurchaseIdCache = {}, Money = 0 },
LastSavedData = { PurchaseIdCache = {} },
active = true,
saves = 0,
}
function p:IsActive()
return self.active
end
function p:Save()
self.saves += 1
if saveWorks then
self.LastSavedData = deepcopy(self.Data)
else
self.active = false -- 저장 실패 끝에 세션이 끝난 상황
end
end
p.OnAfterSave = { Wait = function() end }
return p
end
local p = fakeProfile(true)
local grants = 0
local function grant()
grants += 1
p.Data.Money += 100
return true
end
T.eq(Receipts.process(p, "A", grant), "Granted", "첫 결제 지급")
T.eq(grants, 1, "지급 1회")
T.eq(p.Data.Money, 100, "돈 들어옴")
T.check(table.find(p.LastSavedData.PurchaseIdCache, "A") ~= nil, "저장된 데이터에 PurchaseId 기록")
T.eq(Receipts.process(p, "A", grant), "Granted", "같은 결제 재시도도 완료로 답함")
T.eq(grants, 1, "같은 결제는 다시 지급하지 않음")
T.eq(Receipts.process(p, "B", grant), "Granted", "다른 결제는 지급")
T.eq(grants, 2, "지급 2회")
T.eq(Receipts.process(nil, "C", grant), "NotProcessedYet", "프로필 없으면 나중에")
T.eq(grants, 2, "프로필 없으면 지급 안 함")
local q = fakeProfile(true)
T.eq(
Receipts.process(q, "X", function()
return false
end),
"NotProcessedYet",
"지급 실패면 나중에"
)
T.eq(#q.Data.PurchaseIdCache, 0, "실패한 결제는 기록 안 함")
T.eq(
Receipts.process(q, "Y", function()
error("boom")
end),
"NotProcessedYet",
"지급 중 오류면 나중에"
)
local r = fakeProfile(false)
local rg = 0
T.eq(
Receipts.process(r, "Z", function()
rg += 1
return true
end),
"NotProcessedYet",
"저장 확인 못 하면 완료로 답하지 않음"
)
local c = fakeProfile(true)
for i = 1, Receipts.CACHE_SIZE + 5 do
Receipts.process(c, "P" .. i, function()
return true
end)
end
T.eq(#c.Data.PurchaseIdCache, Receipts.CACHE_SIZE, "기록은 최근 100개까지")
T.done("Receipts.spec")