mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-16 12:23:09 +00:00
moves relativePath method to fsService
This commit is contained in:
parent
5f0e410530
commit
c811b67807
@ -29,6 +29,7 @@ export const mockFsService = {
|
||||
readJsonFile: vi.fn(),
|
||||
writeJsonFile: vi.fn(),
|
||||
writeFile: vi.fn(),
|
||||
toRelativePath: vi.fn(),
|
||||
};
|
||||
|
||||
export const mockShellService = {
|
||||
|
||||
@ -119,7 +119,6 @@ export class ConfigService {
|
||||
};
|
||||
|
||||
toRelative = (str) => {
|
||||
throw new Error("This code does not belong in this file. Move it.");
|
||||
return path.relative(this.config.codexInstallPath, str);
|
||||
return this.fs.toRelativePath(this.config.codexInstallPath, str);
|
||||
};
|
||||
}
|
||||
|
||||
@ -169,6 +169,9 @@ describe("ConfigService", () => {
|
||||
it("writes the config file values to the config TOML file", () => {
|
||||
const publicIp = "1.2.3.4";
|
||||
const bootstrapNodes = ["boot111", "boot222", "boot333"];
|
||||
const relativeDataDirPath = "..\\../datadir";
|
||||
|
||||
mockFsService.toRelativePath.mockReturnValue(relativeDataDirPath);
|
||||
|
||||
configService.writeCodexConfigFile(publicIp, bootstrapNodes);
|
||||
|
||||
@ -176,7 +179,7 @@ describe("ConfigService", () => {
|
||||
|
||||
expect(mockFsService.writeFile).toHaveBeenCalledWith(
|
||||
expectedDefaultConfig.codexConfigFilePath,
|
||||
`data-dir=\"${formatPath(expectedDefaultConfig.dataDir)}"${newLine}` +
|
||||
`data-dir=\"${formatPath(relativeDataDirPath)}"${newLine}` +
|
||||
`log-level="DEBUG"${newLine}` +
|
||||
`log-file="${formatPath(logsPath)}"${newLine}` +
|
||||
`storage-quota=${expectedDefaultConfig.storageQuota}${newLine}` +
|
||||
@ -191,6 +194,11 @@ describe("ConfigService", () => {
|
||||
})
|
||||
.join(",")}]${newLine}`,
|
||||
);
|
||||
|
||||
expect(mockFsService.toRelativePath).toHaveBeenCalledWith(
|
||||
expectedDefaultConfig.codexInstallPath,
|
||||
expectedDefaultConfig.dataDir,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -66,4 +66,8 @@ export class FsService {
|
||||
writeFile = (filePath, content) => {
|
||||
fs.writeFileSync(filePath, content);
|
||||
};
|
||||
|
||||
toRelativePath = (from, to) => {
|
||||
return path.relative(from, to);
|
||||
};
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export class MainMenu {
|
||||
};
|
||||
|
||||
showNotRunningMenu = async () => {
|
||||
await this.ui.askMultipleChoice("Codex is not running", [
|
||||
await this.ui.askMultipleChoice("Codex is installed but not running", [
|
||||
{
|
||||
label: "Start Codex",
|
||||
action: this.processControl.startCodexProcess,
|
||||
|
||||
@ -127,7 +127,7 @@ describe("mainmenu", () => {
|
||||
await mainmenu.showNotRunningMenu();
|
||||
|
||||
expect(mockUiService.askMultipleChoice).toHaveBeenCalledWith(
|
||||
"Codex is not running",
|
||||
"Codex is installed but not running",
|
||||
[
|
||||
{
|
||||
label: "Start Codex",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user