Push-Historie: Obergrenze beim Blättern, Test für HeadCommit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e409c11d5c
commit
51c4852488
2 files changed
+49
-3
No files matched your search
@@ -68,10 +68,26 @@ function manyPushes(base) {
|
||||
return entries
|
||||
}
|
||||
|
||||
/**
|
||||
* Mehr als 40*50 Eintraege, alle nur Minuten auseinander und damit weit innerhalb jedes
|
||||
* 30-Tage-Fensters - fuer den Test der Blaetter-Obergrenze (die Seite wird nie leer/kurz,
|
||||
* und der "aeltester Eintrag vor since"-Stopp greift nie).
|
||||
*/
|
||||
function packedPushes(base, count) {
|
||||
const entries = []
|
||||
for (let i = 0; i < count; i++) {
|
||||
entries.push(pushEntry({ sha: `p${i}`, at: new Date(base.getTime() - i * 60000).toISOString() }))
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
fake = await startFakeGitea({
|
||||
repos: [{ full_name: 'knso/viel' }],
|
||||
feeds: { 'knso/viel': manyPushes(now) },
|
||||
repos: [{ full_name: 'knso/viel' }, { full_name: 'knso/endlos' }],
|
||||
feeds: {
|
||||
'knso/viel': manyPushes(now),
|
||||
'knso/endlos': packedPushes(now, 2005),
|
||||
},
|
||||
})
|
||||
Object.assign(process.env, {
|
||||
GITEA_BASE_URL: fake.baseUrl,
|
||||
@@ -99,6 +115,10 @@ test('HeadCommit bestimmt commitSha', () => {
|
||||
const [p] = pushesFromFeed([pushEntry({ commits: ['c2', 'c1'], head: 'c2' })], { since: new Date(0) })
|
||||
assert.equal(p.commitSha, 'c2'); assert.equal(p.commits.length, 2)
|
||||
})
|
||||
test('HeadCommit hat Vorrang vor dem ersten Commit', () => {
|
||||
const [p] = pushesFromFeed([pushEntry({ commits: ['c1', 'c2'], head: 'c2' })], { since: new Date(0) })
|
||||
assert.equal(p.commitSha, 'c2')
|
||||
})
|
||||
test('ohne HeadCommit gilt der erste Commit', () => {
|
||||
const [p] = pushesFromFeed([pushEntry({ commits: ['c2', 'c1'], head: null })], { since: new Date(0) })
|
||||
assert.equal(p.commitSha, 'c2')
|
||||
@@ -118,3 +138,17 @@ test('listRecentPushes blättert nur so weit wie nötig', async () => {
|
||||
assert.equal(r.length, 90)
|
||||
assert.equal(fake.calls.filter((c) => c.path.includes('/activities/feeds')).length, 2)
|
||||
})
|
||||
test('Blättern hat eine Obergrenze', async () => {
|
||||
// Feed liefert auf jeder Seite 50 volle, aktuelle Einträge - ohne Obergrenze würde
|
||||
// listRecentPushes endlos weiterblättern.
|
||||
const originalWarn = console.warn
|
||||
console.warn = () => {}
|
||||
let r
|
||||
try {
|
||||
r = await listRecentPushes('knso/endlos', { now })
|
||||
} finally {
|
||||
console.warn = originalWarn
|
||||
}
|
||||
assert.equal(r.length, 2000)
|
||||
assert.equal(fake.calls.filter((c) => c.path.includes('/knso/endlos/activities/feeds')).length, 40)
|
||||
})
|
||||
Reference in new issue
Block a user