mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-02 13:33:11 +00:00
Handles the presense of previous versions of the config file
This commit is contained in:
parent
25000aa807
commit
367b889055
@ -55,6 +55,12 @@ export class ConfigService {
|
||||
this.saveConfig();
|
||||
} else {
|
||||
this.config = this.fs.readJsonFile(filePath);
|
||||
|
||||
if (this.config.codexRoot == undefined) {
|
||||
this.config = defaultConfig;
|
||||
this.saveConfig();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
|
||||
@ -53,6 +53,7 @@ describe("ConfigService", () => {
|
||||
it("loads the config.json file when it does exist", () => {
|
||||
mockFsService.isFile.mockReturnValue(true);
|
||||
const savedConfig = {
|
||||
codexRoot: "defined",
|
||||
isTestConfig: "Yes, very",
|
||||
};
|
||||
mockFsService.readJsonFile.mockReturnValue(savedConfig);
|
||||
@ -64,6 +65,22 @@ describe("ConfigService", () => {
|
||||
expect(mockFsService.writeJsonFile).not.toHaveBeenCalled();
|
||||
expect(service.config).toEqual(savedConfig);
|
||||
});
|
||||
|
||||
it("saves the default config when config.json exists but doesn't define the codexRoot", () => {
|
||||
mockFsService.isFile.mockReturnValue(true);
|
||||
const savedConfig = {
|
||||
codexRoot: undefined, // it still blows my mind we have a language in which we can define things to be undefined.
|
||||
isTestConfig: "Yes, very",
|
||||
};
|
||||
mockFsService.readJsonFile.mockReturnValue(savedConfig);
|
||||
|
||||
const service = new ConfigService(mockFsService, mockOsService);
|
||||
|
||||
expect(mockFsService.isFile).toHaveBeenCalledWith(configPath);
|
||||
expect(mockFsService.readJsonFile).toHaveBeenCalledWith(configPath);
|
||||
expect(mockFsService.writeJsonFile).toHaveBeenCalled();
|
||||
expect(service.config).toEqual(expectedDefaultConfig);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getCodexExe", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user