提交 0fdca19f 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

rename Bridge to Manager

上级 d3e342c7
#!/usr/bin/env ts-node
// tslint:disable:no-shadowed-variable
import test from 'blue-tape'
import { MemoryCard } from 'memory-card'
import { Bridge } from './bridge'
import {
WECHATY_PUPPET_PADCHAT_ENDPOINT,
} from './config'
class BridgeTest extends Bridge {
public async initCache(token: string, selfId: string) {
return super.initCache(
token,
selfId,
)
}
public async releaseCache() {
return super.releaseCache()
}
}
test('smoke testing', async t => {
t.skip('tbw')
})
test('bridge cache should be release and can be re-init again.', async t => {
const bridge = new BridgeTest({
memory : new MemoryCard(),
token : 'mock token',
endpoint : WECHATY_PUPPET_PADCHAT_ENDPOINT,
})
try {
await bridge.initCache('fake-token', 'fake-self-id')
await bridge.releaseCache()
await bridge.initCache('fake-token', 'fake-self-id')
t.pass('bridge cache init/release/init successed.')
} catch (e) {
t.fail(e)
}
})
test('bridge should can be restart() after a start()', async t => {
const bridge = new Bridge({
memory : new MemoryCard(),
token : 'mock token',
endpoint : WECHATY_PUPPET_PADCHAT_ENDPOINT,
})
try {
await bridge.start()
await bridge.stop()
await bridge.start()
t.pass('bridge start/restart successed.')
} catch (e) {
t.fail(e)
}
})
......@@ -69,10 +69,10 @@ import {
} from './config'
import {
Bridge,
PadchatManager,
// resolverDict,
// AutoDataType,
} from './bridge'
} from './padchat-manager'
import {
// PadchatPayload,
......@@ -104,7 +104,7 @@ export class PuppetPadchat extends Puppet {
private readonly cachePadchatMessagePayload : LRU.Cache<string, PadchatMessagePayload>
// private readonly cachePadchatRoomPayload : LRU.Cache<string, PadchatRoomRawPayload>
public bridge?: Bridge
public bridge?: PadchatManager
constructor(
public options: PuppetOptions,
......@@ -187,7 +187,7 @@ export class PuppetPadchat extends Puppet {
*/
this.state.on('pending')
const bridge = this.bridge = new Bridge({
const bridge = this.bridge = new PadchatManager({
memory : this.options.memory,
token : padchatToken(),
endpoint : WECHATY_PUPPET_PADCHAT_ENDPOINT,
......@@ -208,7 +208,7 @@ export class PuppetPadchat extends Puppet {
this.bridge.syncContactsAndRooms()
}
public async startBridge(bridge: Bridge): Promise<void> {
public async startBridge(bridge: PadchatManager): Promise<void> {
log.verbose('PuppetPadchat', 'startBridge()')
if (this.state.off()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册