mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-04 06:23:07 +00:00
fixes tests for configService
This commit is contained in:
parent
03dd11d57e
commit
3ee6425200
@ -9,9 +9,8 @@ import {
|
|||||||
getCodexLogsDefaultPath,
|
getCodexLogsDefaultPath,
|
||||||
} from "../utils/appData.js";
|
} from "../utils/appData.js";
|
||||||
|
|
||||||
describe("ConfigService", () => {
|
function getDefaultConfig() {
|
||||||
const configPath = "/path/to/config.json";
|
return {
|
||||||
const expectedDefaultConfig = {
|
|
||||||
codexExe: "",
|
codexExe: "",
|
||||||
codexInstallPath: getCodexBinPath(),
|
codexInstallPath: getCodexBinPath(),
|
||||||
codexConfigFilePath: getCodexConfigFilePath(),
|
codexConfigFilePath: getCodexConfigFilePath(),
|
||||||
@ -24,9 +23,15 @@ describe("ConfigService", () => {
|
|||||||
apiPort: 8080,
|
apiPort: 8080,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("ConfigService", () => {
|
||||||
|
const configPath = "/path/to/config.json";
|
||||||
|
var expectedDefaultConfig = getDefaultConfig();
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
|
expectedDefaultConfig = getDefaultConfig();
|
||||||
|
|
||||||
mockFsService.pathJoin.mockReturnValue(configPath);
|
mockFsService.pathJoin.mockReturnValue(configPath);
|
||||||
});
|
});
|
||||||
@ -92,7 +97,8 @@ describe("ConfigService", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
config = expectedDefaultConfig;
|
config = expectedDefaultConfig;
|
||||||
|
config.codexExe = "codex.exe";
|
||||||
|
|
||||||
configService = new ConfigService(mockFsService);
|
configService = new ConfigService(mockFsService);
|
||||||
configService.config = config;
|
configService.config = config;
|
||||||
});
|
});
|
||||||
@ -105,7 +111,41 @@ describe("ConfigService", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("throws when codexConfigFilePath is not set", () => {
|
||||||
|
config.codexConfigFilePath = "";
|
||||||
|
|
||||||
|
expect(configService.validateConfiguration).toThrow(
|
||||||
|
"Missing config value: codexConfigFilePath",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws when dataDir is not set", () => {
|
||||||
|
config.dataDir = "";
|
||||||
|
|
||||||
|
expect(configService.validateConfiguration).toThrow(
|
||||||
|
"Missing config value: dataDir",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws when logsDir is not set", () => {
|
||||||
|
config.logsDir = "";
|
||||||
|
|
||||||
|
expect(configService.validateConfiguration).toThrow(
|
||||||
|
"Missing config value: logsDir",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws when storageQuota is less than 100 MB", () => {
|
||||||
|
config.storageQuota = 1024 * 1024 * 99;
|
||||||
|
|
||||||
|
expect(configService.validateConfiguration).toThrow(
|
||||||
|
"Storage quota must be at least 100MB",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes validation for default config when codexExe is set", () => {
|
||||||
|
expect(configService.validateConfiguration).not.toThrow();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("writecodexConfigFile", () => {
|
describe("writecodexConfigFile", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user