fix: improve idempotency of ap test

This commit is contained in:
Julian Lam
2026-03-19 12:02:26 -04:00
parent ebe709da89
commit 8ca34e74bd

View File

@@ -737,6 +737,10 @@ describe('Pruning', () => {
}); });
describe('Users', () => { describe('Users', () => {
before(async function () {
this.current = await activitypub.actors.prune();
});
it('should do nothing if the user is newer than the prune cutoff', async () => { it('should do nothing if the user is newer than the prune cutoff', async () => {
const { id: uid } = helpers.mocks.person(); const { id: uid } = helpers.mocks.person();
await activitypub.actors.assert([uid]); await activitypub.actors.assert([uid]);
@@ -762,7 +766,7 @@ describe('Pruning', () => {
assert(result.counts.deleted >= 1); assert(result.counts.deleted >= 1);
}); });
it('should do nothing if the user has some content (e.g. a topic)', async () => { it('should do nothing if the user has some content (e.g. a topic)', async function () {
const { cid } = await categories.create({ name: utils.generateUUID() }); const { cid } = await categories.create({ name: utils.generateUUID() });
const { id: uid } = helpers.mocks.person(); const { id: uid } = helpers.mocks.person();
const { id, note } = helpers.mocks.note({ const { id, note } = helpers.mocks.note({
@@ -776,7 +780,7 @@ describe('Pruning', () => {
const result = await activitypub.actors.prune(); const result = await activitypub.actors.prune();
assert.strictEqual(result.counts.deleted, 0); assert.strictEqual(result.counts.deleted, 0);
assert.strictEqual(result.counts.preserved, 1); assert.strictEqual(result.counts.preserved, this.current.counts.preserved + 1);
assert.strictEqual(result.counts.missing, 0); assert.strictEqual(result.counts.missing, 0);
}); });
}); });