Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-db/src/redis/publisher.spec.ts
2500 views
1
/**
2
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { suite, test } from "@testdeck/mocha";
8
import * as chai from "chai";
9
import { RedisPublisher } from "./publisher";
10
import { Container, ContainerModule } from "inversify";
11
import { Redis } from "ioredis";
12
13
const expect = chai.expect;
14
const RedisMock = require("ioredis-mock");
15
16
@suite
17
class TestRedisPublisher {
18
protected container: Container;
19
20
public before() {
21
const client = new RedisMock() as Redis;
22
23
this.container = new Container();
24
this.container.load(
25
new ContainerModule((bind) => {
26
bind(Redis).toConstantValue(client);
27
bind(RedisPublisher).toSelf().inSingletonScope();
28
}),
29
);
30
}
31
32
@test public publishInstanceUpdate() {
33
const publisher = this.container.get(RedisPublisher);
34
expect(async () => {
35
await publisher.publishInstanceUpdate({
36
ownerID: "123-owner",
37
instanceID: "123",
38
workspaceID: "foo-bar-123",
39
});
40
}).not.to.throw;
41
}
42
}
43
module.exports = new TestRedisPublisher();
44
45