hookshot/tests/config/config.ts
Will Hunt 082a61f802
Split cache config from queue config. (#902)
* Split out queue and cache config

* Update usages of cache config,

* Update default

* Cleanup

* Make queue optional.

* config updates.

* changelog

* update spec config

* Update tests

* tweak import

* Update default config.

* fixup test

* Update config.sample.yml

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* Update encryption.md

Signed-off-by: Will Hunt <will@half-shot.uk>

* Clear up worker config

Signed-off-by: Will Hunt <will@half-shot.uk>

* Update src/config/Config.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* update helm config

* lint

* fix meta

* tidy tidy

* revert logging change

* lint rust

---------

Signed-off-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2024-03-19 16:45:52 +00:00

76 lines
2.9 KiB
TypeScript

import { BridgeConfig } from "../../src/config/Config";
import { DefaultConfigRoot } from "../../src/config/Defaults";
import { expect } from "chai";
describe("Config/BridgeConfig", () => {
describe("will handle the legacy queue.monolitihc option", () => {
it("with no parameters", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
monolithic: true
}});
expect(config.queue).to.be.undefined;
expect(config.cache?.redisUri).to.equal("redis://localhost:6379");
});
it("with a host parameter", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
monolithic: true,
host: 'bark'
}});
expect(config.queue).to.be.undefined;
expect(config.cache?.redisUri).to.equal("redis://bark:6379");
});
it("with a port parameter", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
monolithic: true,
port: 6379,
}});
expect(config.queue).to.be.undefined;
expect(config.cache?.redisUri).to.equal("redis://localhost:6379");
});
it("with a host and port parameter", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
monolithic: true,
host: 'bark',
port: 6379,
}});
expect(config.queue).to.be.undefined;
expect(config.cache?.redisUri).to.equal("redis://bark:6379");
});
it("with monolithic disabled", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
monolithic: false
}});
expect(config.queue).to.deep.equal({
monolithic: false,
});
expect(config.cache?.redisUri).to.equal("redis://localhost:6379");
});
});
describe("will handle the queue option", () => {
it("with redisUri", () => {
const config = new BridgeConfig({ ...DefaultConfigRoot, queue: {
redisUri: "redis://localhost:6379"
}, cache: undefined});
expect(config.queue).to.deep.equal({
redisUri: "redis://localhost:6379"
});
expect(config.cache).to.be.undefined;
});
});
describe("will handle the cache option", () => {
it("with redisUri", () => {
const config = new BridgeConfig({
...DefaultConfigRoot,
cache: {
redisUri: "redis://localhost:6379"
},
queue: undefined,
});
expect(config.cache).to.deep.equal({
redisUri: "redis://localhost:6379"
});
expect(config.queue).to.be.undefined;
});
});
})