@@ -759,6 +759,66 @@ test('should use host specified by the --s3_host option', (t) => {
759759 } ;
760760 } ;
761761
762+ const parsed_package_json = {
763+ name : 'test' ,
764+ main : 'test.js' ,
765+ version : '0.1.0' ,
766+ binary : {
767+ module_name : 'binary-module-name' ,
768+ module_path : 'binary-module-path' ,
769+ host : 's3-production-path' ,
770+ development_host : 's3-development-path' ,
771+ staging_host : 's3-staging-path'
772+ }
773+ } ;
774+
775+ const hosts = [ 'production' , 'staging' , 'development' ] ;
776+ const cmds = [ 'install' , 'info' , 'publish' , 'unpublish' ] ;
777+ cmds . forEach ( ( cmd ) => {
778+ hosts . forEach ( ( host ) => {
779+ const checkAgainst = host !== 'production' ? `${ host } _host` : 'host' ;
780+ const cloned = JSON . parse ( JSON . stringify ( parsed_package_json ) ) ;
781+ const opts = versioning . evaluate ( cloned , makeOoptions ( cmd , host ) ) ;
782+
783+ t . equal ( opts . host , parsed_package_json . binary [ checkAgainst ] + '/' ) ;
784+ t . equal ( opts . hosted_path , parsed_package_json . binary [ checkAgainst ] + '/' ) ;
785+ t . equal ( opts . hosted_tarball , parsed_package_json . binary [ checkAgainst ] + '/' + opts . package_name ) ;
786+ } ) ;
787+ } ) ;
788+ cmds . forEach ( ( cmd ) => {
789+ hosts . forEach ( ( host ) => {
790+ parsed_package_json . binary = {
791+ module_name : 'binary-module-name' ,
792+ module_path : 'binary-module-path' ,
793+ host : { endpoint : 's3-production-path' } ,
794+ development_host : { endpoint : 's3-development-path' } ,
795+ staging_host : { endpoint : 's3-staging-path' }
796+ } ;
797+
798+ const checkAgainst = host !== 'production' ? `${ host } _host` : 'host' ;
799+ const cloned = JSON . parse ( JSON . stringify ( parsed_package_json ) ) ;
800+ const opts = versioning . evaluate ( cloned , makeOoptions ( cmd , host ) ) ;
801+
802+ t . equal ( opts . host , parsed_package_json . binary [ checkAgainst ] . endpoint + '/' ) ;
803+ t . equal ( opts . hosted_path , parsed_package_json . binary [ checkAgainst ] . endpoint + '/' ) ;
804+ t . equal ( opts . hosted_tarball , parsed_package_json . binary [ checkAgainst ] . endpoint + '/' + opts . package_name ) ;
805+ } ) ;
806+ } ) ;
807+ t . end ( ) ;
808+ } ) ;
809+
810+ test ( 'should use host specified by the --s3_host option (production_host used)' , ( t ) => {
811+ const makeOoptions = ( cmd , host ) => {
812+ return {
813+ s3_host : host ,
814+ argv : {
815+ remain : [ cmd ] ,
816+ cooked : [ cmd , '--s3_host' , host ] ,
817+ original : [ cmd , `--s3_host=${ host } ` ]
818+ }
819+ } ;
820+ } ;
821+
762822 const parsed_package_json = {
763823 name : 'test' ,
764824 main : 'test.js' ,
0 commit comments