2024-03-19 16:45:52 +00:00
|
|
|
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");
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
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");
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
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");
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
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");
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
it("with monolithic disabled", () => {
|
2024-11-26 16:04:56 +00:00
|
|
|
const config = new BridgeConfig({
|
|
|
|
...DefaultConfigRoot,
|
|
|
|
encryption: undefined,
|
|
|
|
queue: {
|
|
|
|
monolithic: false
|
|
|
|
}
|
|
|
|
});
|
2024-03-19 16:45:52 +00:00
|
|
|
expect(config.queue).to.deep.equal({
|
|
|
|
monolithic: false,
|
|
|
|
});
|
|
|
|
expect(config.cache?.redisUri).to.equal("redis://localhost:6379");
|
|
|
|
});
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
describe("will handle the queue option", () => {
|
|
|
|
it("with redisUri", () => {
|
2024-11-26 16:04:56 +00:00
|
|
|
const config = new BridgeConfig({ ...DefaultConfigRoot,
|
|
|
|
encryption: undefined,
|
|
|
|
queue: {
|
|
|
|
redisUri: "redis://localhost:6379"
|
|
|
|
},
|
|
|
|
cache: undefined
|
|
|
|
});
|
2024-03-19 16:45:52 +00:00
|
|
|
expect(config.queue).to.deep.equal({
|
|
|
|
redisUri: "redis://localhost:6379"
|
|
|
|
});
|
|
|
|
expect(config.cache).to.be.undefined;
|
|
|
|
});
|
|
|
|
});
|
2024-11-28 15:04:01 +00:00
|
|
|
|
2024-03-19 16:45:52 +00:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|