Skip to content

Commit 0e4a436

Browse files
committed
fix: Address Copilot suggestions - tolerance bug and pluralization
- Disable tolerance for small exact values (1-2 tracks) to prevent accepting 0 when expecting 1 - Fix pluralization in searchalbum: '1 track' instead of '1 tracks'
1 parent 437edbb commit 0e4a436

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

lib/command-handlers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ async function searchalbum(input, channel) {
645645

646646
let message = `Found ${sortedAlbums.length} albums:\n`;
647647
sortedAlbums.forEach((albumResult) => {
648-
const trackInfo = albumResult.totalTracks ? ` (${albumResult.totalTracks} tracks)` : '';
648+
const trackInfo = albumResult.totalTracks
649+
? ` (${albumResult.totalTracks} ${albumResult.totalTracks === 1 ? 'track' : 'tracks'})`
650+
: '';
649651
message += `> *${albumResult.name}* by _${albumResult.artist}_${trackInfo}\n`;
650652
});
651653
sendMessage(message, channel);

test/tools/integration-test-suite.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,17 @@ const validators = {
596596
// Exact match - no output
597597
if (actualIncrease === exactIncrease) return true;
598598

599-
// Within tolerance (90-100%) - warning but pass
600-
const tolerance = Math.floor(exactIncrease * 0.9);
601-
if (actualIncrease >= tolerance && actualIncrease < exactIncrease) {
602-
console.log(` ⚠️ WARNING: Queue increased by ${actualIncrease} (expected ${exactIncrease}, baseline: ${baseline}${size})`);
603-
return true;
599+
// Disable tolerance for very small expected increases (1-2 tracks),
600+
// where a "90%" tolerance would allow clearly incorrect results (e.g., 0 of 1).
601+
if (exactIncrease >= 3) {
602+
const tolerance = Math.floor(exactIncrease * 0.9);
603+
if (actualIncrease >= tolerance && actualIncrease < exactIncrease) {
604+
console.log(` ⚠️ WARNING: Queue increased by ${actualIncrease} (expected ${exactIncrease}, baseline: ${baseline}${size})`);
605+
return true;
606+
}
604607
}
605608

606-
// Outside tolerance - fail
609+
// Outside tolerance or small exact value - fail
607610
return `❌ FAIL: Queue increased by ${actualIncrease} (expected exactly ${exactIncrease}, baseline: ${baseline}${size})`;
608611
},
609612

0 commit comments

Comments
 (0)