Path: blob/main/components/gitpod-db/src/redis/publisher.spec.ts
2500 views
/**1* Copyright (c) 2022 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { suite, test } from "@testdeck/mocha";7import * as chai from "chai";8import { RedisPublisher } from "./publisher";9import { Container, ContainerModule } from "inversify";10import { Redis } from "ioredis";1112const expect = chai.expect;13const RedisMock = require("ioredis-mock");1415@suite16class TestRedisPublisher {17protected container: Container;1819public before() {20const client = new RedisMock() as Redis;2122this.container = new Container();23this.container.load(24new ContainerModule((bind) => {25bind(Redis).toConstantValue(client);26bind(RedisPublisher).toSelf().inSingletonScope();27}),28);29}3031@test public publishInstanceUpdate() {32const publisher = this.container.get(RedisPublisher);33expect(async () => {34await publisher.publishInstanceUpdate({35ownerID: "123-owner",36instanceID: "123",37workspaceID: "foo-bar-123",38});39}).not.to.throw;40}41}42module.exports = new TestRedisPublisher();434445