-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ws-man-bridge] Publish ws-instance-update * tests * fix * fix
- Loading branch information
Showing
7 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
export const WorkspaceInstanceUpdatesChannel = "chan:workspace-instances"; | ||
|
||
export type RedisWorkspaceInstanceUpdate = { | ||
instanceID: string; | ||
workspaceID: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { suite, test } from "@testdeck/mocha"; | ||
import * as chai from "chai"; | ||
import { RedisPublisher } from "./publisher"; | ||
import { Metrics } from "../metrics"; | ||
import { RedisClient } from "./client"; | ||
import { Container, ContainerModule } from "inversify"; | ||
|
||
const expect = chai.expect; | ||
const Redis = require("ioredis-mock"); | ||
|
||
@suite | ||
class TestRedisPublisher { | ||
protected container: Container; | ||
|
||
public before() { | ||
const client = { | ||
get: () => new Redis(), | ||
} as RedisClient; | ||
|
||
this.container = new Container(); | ||
this.container.load( | ||
new ContainerModule((bind) => { | ||
bind(Metrics).toSelf().inSingletonScope(); | ||
bind(RedisClient).toConstantValue(client); | ||
bind(RedisPublisher).toSelf().inSingletonScope(); | ||
}), | ||
); | ||
} | ||
|
||
@test public publishInstanceUpdate() { | ||
const publisher = this.container.get(RedisPublisher); | ||
expect(() => { | ||
publisher.publishInstanceUpdate({ | ||
instanceID: "123", | ||
workspaceID: "foo-bar-123", | ||
}); | ||
}).not.to.throw; | ||
} | ||
} | ||
module.exports = new TestRedisPublisher(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters