feat: add extensive test suite

This commit is contained in:
2026-08-30 11:33:53 +07:00 Unverified
parent 061cce00dc
commit 8359c7272e
131 changed files with 8717 additions and 2200 deletions
+18 -12
View File
@@ -4,18 +4,24 @@ import { gt, sum } from "drizzle-orm";
import { getArtifactConfig } from "@/lib/api";
import { db } from "@/lib/db";
import { donations, settings } from "@/lib/db/schema";
import { getDonationGoal } from "../service";
export async function getDonateBar() {
const { donateGoalStarting } = await getArtifactConfig();
const [{ amount }] = await db
.select({
amount: sum(donations.amount),
})
.from(donations)
.where(gt(donations.created, donateGoalStarting ?? new Date(0)));
const [{ goal }] = await db
.select({ goal: settings.donateGoal })
.from(settings)
.limit(1);
return { amount, goal };
return getDonationGoal({
getGoalStart: async () => (await getArtifactConfig()).donateGoalStarting,
async sumSince(starting) {
const [{ amount }] = await db
.select({ amount: sum(donations.amount) })
.from(donations)
.where(gt(donations.created, starting));
return amount;
},
async getGoal() {
const [{ goal }] = await db
.select({ goal: settings.donateGoal })
.from(settings)
.limit(1);
return goal;
},
});
}