Skip to content

Commit

Permalink
Comments for untestable codepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
fry69 committed Apr 16, 2024
1 parent 93c4532 commit feb5566
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions files-to-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ProcessingConfig {
gitignoreRules: string[];
}

// These two functions allow redirecting the output via mock functions, they get implicitly tested
export function output(...args: any[]) {
console.log(...args);
}
Expand Down Expand Up @@ -48,6 +49,10 @@ async function processFile(filePath: string): Promise<void> {
output('---');
}
} catch (err) {
// This should not happen unless e.g. files get deleted while this tool runs
// I ran into this case as the test framework was cleaning up files before this tool was done
// Remove `Bun.sleep()` from the test script and you will end up here
// TODO: write test case (not trivial)
error(`Error processing file ${filePath}: ${err}`);
}
}
Expand Down

0 comments on commit feb5566

Please # to comment.