11import { expect } from "chai"
22import got from "got"
33import { Client } from "../../src"
4- import {
5- createClient ,
6- createStreamName ,
7- } from "../support/fake_data"
4+ import { createClient , createStreamName } from "../support/fake_data"
85import { Rabbit , RabbitConnectionResponse } from "../support/rabbit"
9- import {
10- getTestNodesFromEnv ,
11- password ,
12- username ,
13- } from "../support/util"
6+ import { getTestNodesFromEnv , password , username } from "../support/util"
147
158async function createVhost ( vhost : string ) : Promise < undefined > {
169 const port = process . env . RABBIT_MQ_MANAGEMENT_PORT || 15672
1710 const firstNode = getTestNodesFromEnv ( ) . shift ( ) !
18- await got . put < RabbitConnectionResponse > (
19- `http://${ firstNode . host } :${ port } /api/vhosts/${ vhost } ` ,
20- {
21- username : username ,
22- password : password ,
23- }
24- )
25- await got . put < RabbitConnectionResponse > (
26- `http://${ firstNode . host } :${ port } /api/permissions/${ vhost } /${ username } ` ,
27- {
11+ await got . put < RabbitConnectionResponse > ( `http://${ firstNode . host } :${ port } /api/vhosts/${ vhost } ` , {
12+ username : username ,
13+ password : password ,
14+ } )
15+ await got
16+ . put < RabbitConnectionResponse > ( `http://${ firstNode . host } :${ port } /api/permissions/${ vhost } /${ username } ` , {
2817 json : {
29- read : '.*' ,
30- write : '.*' ,
31- configure : '.*'
18+ read : ".*" ,
19+ write : ".*" ,
20+ configure : ".*" ,
3221 } ,
3322 username : username ,
3423 password : password ,
35- }
36- ) . json ( )
24+ } )
25+ . json ( )
3726}
3827
3928async function deleteVhost ( vhost : string ) : Promise < RabbitConnectionResponse > {
4029 const port = process . env . RABBIT_MQ_MANAGEMENT_PORT || 15672
4130 const firstNode = getTestNodesFromEnv ( ) . shift ( ) !
42- const r = await got . delete < RabbitConnectionResponse > (
43- `http://${ firstNode . host } :${ port } /api/vhosts/${ vhost } ` ,
44- {
45- username : username ,
46- password : password ,
47- }
48- )
31+ const r = await got . delete < RabbitConnectionResponse > ( `http://${ firstNode . host } :${ port } /api/vhosts/${ vhost } ` , {
32+ username : username ,
33+ password : password ,
34+ } )
4935
5036 return r . body
5137}
@@ -61,15 +47,7 @@ describe("cache", () => {
6147 } )
6248 beforeEach ( async ( ) => {
6349 client = await createClient ( username , password )
64- client2 = await createClient (
65- username ,
66- password ,
67- undefined ,
68- undefined ,
69- undefined ,
70- undefined ,
71- undefined ,
72- vhost1 )
50+ client2 = await createClient ( username , password , undefined , undefined , undefined , undefined , undefined , vhost1 )
7351 streamName = createStreamName ( )
7452 await client . createStream ( { stream : streamName } )
7553 await client2 . createStream ( { stream : streamName } )
@@ -82,7 +60,7 @@ describe("cache", () => {
8260 await rabbit . deleteStream ( streamName )
8361 await rabbit . closeAllConnections ( )
8462 await rabbit . deleteAllQueues ( { match : / m y - s t r e a m - / } )
85- } catch ( _e ) { }
63+ } catch ( _e ) { }
8664 } )
8765
8866 it ( "should cache using the vhost as well as the stream name" , async ( ) => {
0 commit comments