@@ -800,7 +800,7 @@ export class SessionManager {
|
|||||||
if (this.fileEntries.length === 0) {
|
if (this.fileEntries.length === 0) {
|
||||||
const explicitPath = this.sessionFile;
|
const explicitPath = this.sessionFile;
|
||||||
if (statSync(explicitPath).size > 0) {
|
if (statSync(explicitPath).size > 0) {
|
||||||
throw new Error(`Session file is not a valid pi session and was not modified: ${explicitPath}`);
|
throw new Error(`Session file is not a valid pi session: ${explicitPath}`);
|
||||||
}
|
}
|
||||||
this.newSession();
|
this.newSession();
|
||||||
this.sessionFile = explicitPath;
|
this.sessionFile = explicitPath;
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ describe("--session invalid file handling", () => {
|
|||||||
const result = await runCli(["--session", sessionFile, "-p", "hi"], projectDir, agentDir);
|
const result = await runCli(["--session", sessionFile, "-p", "hi"], projectDir, agentDir);
|
||||||
|
|
||||||
expect(result.code).toBe(1);
|
expect(result.code).toBe(1);
|
||||||
expect(result.stderr).toContain(
|
expect(result.stderr).toContain(`Error: Session file is not a valid pi session: ${sessionFile}`);
|
||||||
`Error: Session file is not a valid pi session and was not modified: ${sessionFile}`,
|
|
||||||
);
|
|
||||||
expect(result.stderr).not.toContain("SessionManager.open");
|
expect(result.stderr).not.toContain("SessionManager.open");
|
||||||
expect(result.stderr).not.toContain("at ");
|
expect(result.stderr).not.toContain("at ");
|
||||||
expect(readFileSync(sessionFile, "utf8")).toBe(originalContent);
|
expect(readFileSync(sessionFile, "utf8")).toBe(originalContent);
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ describe("SessionManager.setSessionFile with corrupted files", () => {
|
|||||||
writeFileSync(noHeaderFile, originalContent);
|
writeFileSync(noHeaderFile, originalContent);
|
||||||
|
|
||||||
expect(() => SessionManager.open(noHeaderFile, tempDir)).toThrow(
|
expect(() => SessionManager.open(noHeaderFile, tempDir)).toThrow(
|
||||||
`Session file is not a valid pi session and was not modified: ${noHeaderFile}`,
|
`Session file is not a valid pi session: ${noHeaderFile}`,
|
||||||
);
|
);
|
||||||
expect(readFileSync(noHeaderFile, "utf-8")).toBe(originalContent);
|
expect(readFileSync(noHeaderFile, "utf-8")).toBe(originalContent);
|
||||||
});
|
});
|
||||||
@@ -286,7 +286,7 @@ describe("SessionManager.setSessionFile with corrupted files", () => {
|
|||||||
writeFileSync(nonSessionFile, originalContent);
|
writeFileSync(nonSessionFile, originalContent);
|
||||||
|
|
||||||
expect(() => SessionManager.open(nonSessionFile, tempDir)).toThrow(
|
expect(() => SessionManager.open(nonSessionFile, tempDir)).toThrow(
|
||||||
`Session file is not a valid pi session and was not modified: ${nonSessionFile}`,
|
`Session file is not a valid pi session: ${nonSessionFile}`,
|
||||||
);
|
);
|
||||||
expect(readFileSync(nonSessionFile, "utf-8")).toBe(originalContent);
|
expect(readFileSync(nonSessionFile, "utf-8")).toBe(originalContent);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user