2020-02-25 21:14:44 +08:00
'use strict' ;
const assert = require ( 'assert' ) ;
const TestClient = require ( '../support/test-client' ) ;
2020-04-29 16:40:45 +08:00
const MetricsBackend = require ( '../../lib/backends/metrics' ) ;
2020-04-28 00:40:28 +08:00
const apikey = 1234 ;
2020-02-25 21:14:44 +08:00
const mapConfig = {
2020-04-28 00:02:06 +08:00
version : '1.8.0' ,
2020-02-25 21:14:44 +08:00
layers : [
{
options : {
2020-04-28 00:02:06 +08:00
sql : TestClient . SQL . ONE _POINT ,
2020-02-25 21:14:44 +08:00
cartocss : TestClient . CARTOCSS . POINTS ,
cartocss _version : '2.3.0'
}
}
]
} ;
2020-04-29 01:17:00 +08:00
function templateBuilder ( { name } ) {
return {
version : '0.0.1' ,
name : ` metrics-template- ${ name } ` ,
layergroup : {
version : '1.8.0' ,
layers : [
{
type : 'cartodb' ,
options : {
sql : TestClient . SQL . ONE _POINT ,
cartocss : TestClient . CARTOCSS . POINTS ,
cartocss _version : '2.3.0'
}
2020-04-28 00:40:28 +08:00
}
2020-04-29 01:17:00 +08:00
]
}
} ;
2020-04-28 00:40:28 +08:00
} ;
2020-04-28 00:02:06 +08:00
2020-04-29 16:40:45 +08:00
describe ( 'metrics middleware' , function ( ) {
2020-04-28 00:02:06 +08:00
beforeEach ( function ( ) {
2020-04-29 16:40:45 +08:00
this . originalMetricsBackendSendMethod = MetricsBackend . prototype . send ;
2020-04-28 00:02:06 +08:00
this . pubSubMetricsBackendSendMethodCalled = false ;
2020-04-29 16:40:45 +08:00
MetricsBackend . prototype . send = ( event , attributes ) => {
2020-04-28 00:02:06 +08:00
this . pubSubMetricsBackendSendMethodCalled = true ;
this . pubSubMetricsBackendSendMethodCalledWith = { event , attributes } ;
return Promise . resolve ( ) ;
} ;
2020-02-25 21:14:44 +08:00
} ) ;
2020-04-28 00:02:06 +08:00
afterEach ( function ( ) {
2020-04-29 16:40:45 +08:00
MetricsBackend . prototype . send = this . originalMetricsBackendSendMethod ;
2020-02-25 21:14:44 +08:00
} ) ;
it ( 'should not send event if not enabled' , function ( done ) {
2020-04-28 00:02:06 +08:00
const extraHeaders = {
'Carto-Event' : 'test-event' ,
'Carto-Event-Source' : 'test' ,
'Carto-Event-Group-Id' : '1'
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : false } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
2020-02-25 21:14:44 +08:00
testClient . getLayergroup ( ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
2020-04-28 00:02:06 +08:00
assert . strictEqual ( typeof body . layergroupid , 'string' ) ;
assert . ok ( ! this . pubSubMetricsBackendSendMethodCalled ) ;
return testClient . drain ( done ) ;
2020-02-25 21:14:44 +08:00
} ) ;
} ) ;
it ( 'should not send event if headers not present' , function ( done ) {
2020-04-28 00:02:06 +08:00
const extraHeaders = { } ;
const overrideServerOptions = { pubSubMetrics : { enabled : false } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
2020-02-25 21:14:44 +08:00
testClient . getLayergroup ( ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
2020-04-28 00:02:06 +08:00
assert . strictEqual ( typeof body . layergroupid , 'string' ) ;
assert . ok ( ! this . pubSubMetricsBackendSendMethodCalled ) ;
return testClient . drain ( done ) ;
2020-02-25 21:14:44 +08:00
} ) ;
} ) ;
2020-04-28 00:02:06 +08:00
it ( 'should send event for map requests' , function ( done ) {
2020-04-29 01:17:00 +08:00
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
2020-04-28 00:02:06 +08:00
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
2020-04-28 00:40:28 +08:00
const expectedResponseCode = '200' ;
2020-04-29 01:17:00 +08:00
const expectedMapType = 'anonymous' ;
2020-04-28 00:02:06 +08:00
const extraHeaders = {
2020-04-29 01:17:00 +08:00
'Carto-Event' : expectedMetricsEvent ,
2020-04-28 00:02:06 +08:00
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
2020-02-26 20:24:46 +08:00
testClient . getLayergroup ( ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
2020-04-28 00:02:06 +08:00
assert . strictEqual ( typeof body . layergroupid , 'string' ) ;
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
2020-04-28 00:02:06 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
2020-04-28 00:40:28 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
2020-04-28 00:02:06 +08:00
return testClient . drain ( done ) ;
2020-02-26 20:24:46 +08:00
} ) ;
} ) ;
2020-04-28 00:02:06 +08:00
it ( 'should normalized headers type and length' , function ( done ) {
2020-04-29 01:17:00 +08:00
const expectedEvent = 'map_view' ;
2020-04-28 00:02:06 +08:00
const eventLong = 'If you are sending a text this long in a header you kind of deserve the worst, honestly. I mean this is not a header, it is almost a novel, and you do not see any Novel cookie here, right?' ;
2020-04-29 01:17:00 +08:00
const expectedMetricsEvent = eventLong . trim ( ) . substr ( 0 , 100 ) ;
2020-04-28 00:02:06 +08:00
const expectedEventGroupId = '1' ;
const expectedEventSource = 'test' ;
2020-04-28 00:40:28 +08:00
const expectedResponseCode = '200' ;
2020-04-29 01:17:00 +08:00
const expectedMapType = 'anonymous' ;
2020-04-28 00:02:06 +08:00
const extraHeaders = {
'Carto-Event' : eventLong ,
'Carto-Event-Source' : 'test' ,
'Carto-Event-Group-Id' : 1
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
2020-02-25 21:14:44 +08:00
testClient . getLayergroup ( ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
2020-04-28 00:02:06 +08:00
assert . strictEqual ( typeof body . layergroupid , 'string' ) ;
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
2020-04-28 00:02:06 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
2020-04-28 00:40:28 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
2020-04-28 00:02:06 +08:00
return testClient . drain ( done ) ;
2020-02-25 21:14:44 +08:00
} ) ;
} ) ;
it ( 'should send event when error' , function ( done ) {
2020-04-29 01:17:00 +08:00
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
2020-04-28 00:02:06 +08:00
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
2020-04-28 00:40:28 +08:00
const expectedResponseCode = '400' ;
2020-04-29 01:17:00 +08:00
const expectedMapType = 'anonymous' ;
2020-04-28 00:02:06 +08:00
const extraHeaders = {
2020-04-29 01:17:00 +08:00
'Carto-Event' : expectedMetricsEvent ,
2020-04-28 00:02:06 +08:00
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
2020-04-29 01:17:00 +08:00
const mapConfigMissingCartoCSS = {
version : '1.8.0' ,
layers : [
{
options : {
sql : TestClient . SQL . ONE _POINT ,
cartocss : TestClient . CARTOCSS . POINTS
}
}
]
} ;
const testClient = new TestClient ( mapConfigMissingCartoCSS , apikey , extraHeaders , overrideServerOptions ) ;
2020-04-28 00:02:06 +08:00
const params = { response : { status : 400 } } ;
testClient . getLayergroup ( params , ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
2020-02-25 21:14:44 +08:00
2020-04-28 00:02:06 +08:00
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
2020-04-28 00:02:06 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
2020-04-28 00:40:28 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
2020-04-29 01:17:00 +08:00
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
2020-04-28 00:40:28 +08:00
return testClient . drain ( done ) ;
} ) ;
} ) ;
2020-04-29 01:17:00 +08:00
it . skip ( 'should send event for tile requests' , function ( done ) {
2020-04-28 00:40:28 +08:00
const expectedEvent = 'event-tile-test' ;
const expectedEventSource = 'event-source-tile-test' ;
const expectedEventGroupId = '12345' ;
const expectedResponseCode = '200' ;
const extraHeaders = {
'Carto-Event' : expectedEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
testClient . getTile ( 0 , 0 , 0 , ( err , res , tile ) => {
if ( err ) {
return done ( err ) ;
}
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
2020-04-29 01:17:00 +08:00
it . skip ( 'should send event for errored tile requests' , function ( done ) {
2020-04-28 00:40:28 +08:00
const expectedEvent = 'event-tile-test' ;
const expectedEventSource = 'event-source-tile-test' ;
const expectedEventGroupId = '12345' ;
const expectedResponseCode = '400' ;
const extraHeaders = {
'Carto-Event' : expectedEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const testClient = new TestClient ( mapConfig , apikey , extraHeaders , overrideServerOptions ) ;
const params = {
response : {
status : 400 ,
headers : {
'Content-Type' : 'application/json; charset=utf-8'
}
}
} ;
testClient . getTile ( 0 , 0 , 2 , params , ( err , res , tile ) => {
if ( err ) {
return done ( err ) ;
}
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
2020-04-29 01:17:00 +08:00
it ( 'should send event for named map requests' , function ( done ) {
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
const expectedResponseCode = '200' ;
const expectedMapType = 'named' ;
const extraHeaders = {
'Carto-Event' : expectedMetricsEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const template = templateBuilder ( { name : 'map' } ) ;
const testClient = new TestClient ( template , apikey , extraHeaders , overrideServerOptions ) ;
testClient . getLayergroup ( ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
assert . strictEqual ( typeof body . layergroupid , 'string' ) ;
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
it ( 'should send event for errored named map requests' , function ( done ) {
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
const expectedResponseCode = '400' ;
const expectedMapType = 'named' ;
const extraHeaders = {
'Carto-Event' : expectedMetricsEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const templateMissingCartoCSS = {
version : '0.0.1' ,
name : 'metrics-template' ,
layergroup : {
version : '1.8.0' ,
layers : [
{
type : 'cartodb' ,
options : {
sql : TestClient . SQL . ONE _POINT ,
cartocss : TestClient . CARTOCSS . POINTS
}
}
]
}
} ;
const testClient = new TestClient ( templateMissingCartoCSS , apikey , extraHeaders , overrideServerOptions ) ;
const params = {
response : {
status : 400 ,
headers : {
'Content-Type' : 'application/json; charset=utf-8'
}
}
} ;
testClient . getLayergroup ( params , ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
it . skip ( 'should send event for named map tile requests' , function ( done ) {
2020-04-28 00:40:28 +08:00
const expectedEvent = 'event-named-map-tile-test' ;
const expectedEventSource = 'event-source-named-map-tile-test' ;
const expectedEventGroupId = '1' ;
const expectedResponseCode = '200' ;
const extraHeaders = {
'Carto-Event' : expectedEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
2020-04-29 01:17:00 +08:00
const template = templateBuilder ( { name : 'tile' } ) ;
2020-04-28 00:40:28 +08:00
const testClient = new TestClient ( template , apikey , extraHeaders , overrideServerOptions ) ;
testClient . getTile ( 0 , 0 , 0 , ( err , body ) => {
if ( err ) {
return done ( err ) ;
}
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
2020-02-25 21:14:44 +08:00
2020-04-28 00:02:06 +08:00
return testClient . drain ( done ) ;
2020-02-25 21:14:44 +08:00
} ) ;
} ) ;
2020-04-29 01:17:00 +08:00
it ( 'should send event for static named map requests' , function ( done ) {
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
const expectedResponseCode = '200' ;
const expectedMapType = 'static' ;
const extraHeaders = {
'Carto-Event' : expectedMetricsEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const template = templateBuilder ( { name : 'preview' } ) ;
const testClient = new TestClient ( template , apikey , extraHeaders , overrideServerOptions ) ;
testClient . getPreview ( 640 , 480 , { } , ( err , res , body ) => {
if ( err ) {
return done ( err ) ;
}
assert . ok ( this . pubSubMetricsBackendSendMethodCalled ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
2020-04-29 16:28:10 +08:00
it ( 'should send event for errored static named map requests' , function ( done ) {
const expectedEvent = 'map_view' ;
const expectedMetricsEvent = 'event-test' ;
const expectedEventSource = 'event-source-test' ;
const expectedEventGroupId = '1' ;
const expectedResponseCode = '400' ;
const expectedMapType = 'static' ;
const extraHeaders = {
'Carto-Event' : expectedMetricsEvent ,
'Carto-Event-Source' : expectedEventSource ,
'Carto-Event-Group-Id' : expectedEventGroupId
} ;
const overrideServerOptions = { pubSubMetrics : { enabled : true , topic : 'topic-test' } } ;
const template = templateBuilder ( { name : 'preview-errored' } ) ;
const testClient = new TestClient ( template , apikey , extraHeaders , overrideServerOptions ) ;
const widthTooLarge = 8193 ;
const params = {
response : {
status : 400 ,
headers : {
'Content-Type' : 'application/json; charset=utf-8'
}
}
} ;
testClient . getPreview ( widthTooLarge , 480 , params , ( err , res , body ) => {
if ( err ) {
return done ( err ) ;
}
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . event , expectedEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . metrics _event , expectedMetricsEvent ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _source , expectedEventSource ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . event _group _id , expectedEventGroupId ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . response _code , expectedResponseCode ) ;
assert . strictEqual ( this . pubSubMetricsBackendSendMethodCalledWith . attributes . map _type , expectedMapType ) ;
return testClient . drain ( done ) ;
} ) ;
} ) ;
2020-02-25 21:14:44 +08:00
} ) ;