22
33var Promise = require ( 'ember-cli/lib/ext/promise' ) ;
44var assert = require ( 'ember-cli/tests/helpers/assert' ) ;
5- var CoreObject = require ( 'core-object ' ) ;
5+ var FakeRedis = require ( '../helpers/fake-redis-lib ' ) ;
66
77var stubProject = {
88 name : function ( ) {
99 return 'my-project' ;
1010 }
1111} ;
1212
13- var fakeClient = {
14- createClient : function ( options ) {
15- this . options = options ;
16- return {
17- get : function ( key ) {
18- return Promise . resolve ( 'some-other-value' ) ;
19- } ,
20- set : function ( ) { } ,
21- lpush : function ( ) { } ,
22- ltrim : function ( ) { }
23- }
24- }
25- } ;
26-
2713describe ( 'redis plugin' , function ( ) {
2814 var subject , mockUi ;
2915
@@ -83,6 +69,8 @@ describe('redis plugin', function() {
8369 name : 'redis'
8470 } ) ;
8571
72+ var redisLib = new FakeRedis ( ) ;
73+
8674 var context = {
8775 ui : mockUi ,
8876 project : stubProject ,
@@ -93,15 +81,15 @@ describe('redis plugin', function() {
9381 database : 4
9482 }
9583 } ,
96- _redisLib : fakeClient
84+ _redisLib : redisLib
9785 } ;
9886 plugin . beforeHook ( context ) ;
9987 plugin . configure ( context ) ;
10088 plugin . readConfig ( 'redisDeployClient' ) ;
10189
102- assert . equal ( fakeClient . options . host , 'somehost' ) ;
103- assert . equal ( fakeClient . options . port , 1234 ) ;
104- assert . equal ( fakeClient . options . database , 4 ) ;
90+ assert . equal ( redisLib . createdClient . options . host , 'somehost' ) ;
91+ assert . equal ( redisLib . createdClient . options . port , 1234 ) ;
92+ assert . equal ( redisLib . createdClient . options . database , 4 ) ;
10593 } ) ;
10694
10795 describe ( 'resolving revisionKey from the pipeline' , function ( ) {
@@ -292,6 +280,34 @@ describe('redis plugin', function() {
292280 assert . isDefined ( config . redis . didDeployMessage ) ;
293281 } ) ;
294282 } ) ;
283+
284+ describe ( 'with aliases' , function ( ) {
285+ it ( 'passes config for specified alias to redis' , function ( ) {
286+ var plugin = subject . createDeployPlugin ( {
287+ name : 'foobar'
288+ } ) ;
289+
290+ var redisLib = new FakeRedis ( ) ;
291+
292+ var config = {
293+ database : 7
294+ } ;
295+ var context = {
296+ ui : mockUi ,
297+ project : stubProject ,
298+ config : {
299+ foobar : config
300+ } ,
301+ _redisLib : redisLib
302+ } ;
303+
304+ plugin . beforeHook ( context ) ;
305+ plugin . configure ( context ) ;
306+ plugin . readConfig ( 'redisDeployClient' ) ;
307+
308+ assert . equal ( redisLib . createdClient . options . database , 7 ) ;
309+ } ) ;
310+ } ) ;
295311 } ) ;
296312
297313 describe ( 'upload hook' , function ( ) {
0 commit comments