@@ -251,6 +251,35 @@ describe('Debuglet', () => {
251251 debuglet . start ( ) ;
252252 } ) ;
253253
254+ it ( 'should enable breakpoint canary when enableCanary is set' , done => {
255+ const debug = new Debug (
256+ { projectId : 'fake-project' , credentials : fakeCredentials } ,
257+ packageInfo
258+ ) ;
259+ nocks . oauth2 ( ) ;
260+
261+ const config = debugletConfig ( ) ;
262+ config . serviceContext . enableCanary = true ;
263+ const debuglet = new Debuglet ( debug , config ) ;
264+ const scope = nock ( config . apiUrl )
265+ . post ( REGISTER_PATH )
266+ . reply ( 200 , {
267+ debuggee : { id : DEBUGGEE_ID } ,
268+ } ) ;
269+
270+ debuglet . once ( 'registered' , ( ) => {
271+ assert . strictEqual (
272+ ( debuglet . debuggee as Debuggee ) . canaryMode ,
273+ 'CANARY_MODE_ALWAYS_ENABLED'
274+ ) ;
275+ debuglet . stop ( ) ;
276+ scope . done ( ) ;
277+ done ( ) ;
278+ } ) ;
279+
280+ debuglet . start ( ) ;
281+ } ) ;
282+
254283 it ( 'should not fail if files cannot be read' , done => {
255284 const MOCKED_DIRECTORY = process . cwd ( ) ;
256285 const errors : Array < { filename : string ; error : string } > = [ ] ;
@@ -1465,6 +1494,54 @@ describe('Debuglet', () => {
14651494 assert . ok ( debuggee ) ;
14661495 assert . ok ( debuggee . statusMessage ) ;
14671496 } ) ;
1497+
1498+ it ( 'should be in CANARY_MODE_DEFAULT_ENABLED canaryMode' , ( ) => {
1499+ const debuggee = Debuglet . createDebuggee (
1500+ 'some project' ,
1501+ 'id' ,
1502+ { enableCanary : true , allowCanaryOverride : true } ,
1503+ { } ,
1504+ false ,
1505+ packageInfo
1506+ ) ;
1507+ assert . strictEqual ( debuggee . canaryMode , 'CANARY_MODE_DEFAULT_ENABLED' ) ;
1508+ } ) ;
1509+
1510+ it ( 'should be in CANARY_MODE_ALWAYS_ENABLED canaryMode' , ( ) => {
1511+ const debuggee = Debuglet . createDebuggee (
1512+ 'some project' ,
1513+ 'id' ,
1514+ { enableCanary : true , allowCanaryOverride : false } ,
1515+ { } ,
1516+ false ,
1517+ packageInfo
1518+ ) ;
1519+ assert . strictEqual ( debuggee . canaryMode , 'CANARY_MODE_ALWAYS_ENABLED' ) ;
1520+ } ) ;
1521+
1522+ it ( 'should be in CANARY_MODE_DEFAULT_DISABLED canaryMode' , ( ) => {
1523+ const debuggee = Debuglet . createDebuggee (
1524+ 'some project' ,
1525+ 'id' ,
1526+ { enableCanary : false , allowCanaryOverride : true } ,
1527+ { } ,
1528+ false ,
1529+ packageInfo
1530+ ) ;
1531+ assert . strictEqual ( debuggee . canaryMode , 'CANARY_MODE_DEFAULT_DISABLED' ) ;
1532+ } ) ;
1533+
1534+ it ( 'should be in CANARY_MODE_ALWAYS_DISABLED canaryMode' , ( ) => {
1535+ const debuggee = Debuglet . createDebuggee (
1536+ 'some project' ,
1537+ 'id' ,
1538+ { enableCanary : false , allowCanaryOverride : false } ,
1539+ { } ,
1540+ false ,
1541+ packageInfo
1542+ ) ;
1543+ assert . strictEqual ( debuggee . canaryMode , 'CANARY_MODE_ALWAYS_DISABLED' ) ;
1544+ } ) ;
14681545 } ) ;
14691546
14701547 describe ( '_createUniquifier' , ( ) => {
0 commit comments