@@ -127,12 +127,12 @@ describe('PubSub', function() {
127
127
] ) ;
128
128
} ) ;
129
129
130
- it ( 'should use the PUBSUB_HOST env var' , function ( ) {
130
+ it ( 'should use the PUBSUB_EMULATOR_HOST env var' , function ( ) {
131
131
var pubSubHost = 'pubsub-host' ;
132
- process . env . PUBSUB_HOST = pubSubHost ;
132
+ process . env . PUBSUB_EMULATOR_HOST = pubSubHost ;
133
133
134
134
var pubsub = new PubSub ( { projectId : 'project-id' } ) ;
135
- delete process . env . PUBSUB_HOST ;
135
+ delete process . env . PUBSUB_EMULATOR_HOST ;
136
136
137
137
var calledWith = pubsub . calledWith_ [ 0 ] ;
138
138
assert . strictEqual ( calledWith . baseUrl , pubSubHost ) ;
@@ -719,29 +719,33 @@ describe('PubSub', function() {
719
719
delete process . env . PUBSUB_EMULATOR_HOST ;
720
720
} ) ;
721
721
722
- it ( 'should default to pubsub.googleapis.com/v1 ' , function ( ) {
722
+ it ( 'should default to pubsub.googleapis.com' , function ( ) {
723
723
pubsub . determineBaseUrl_ ( ) ;
724
724
725
- var expectedBaseUrl = 'https:// pubsub.googleapis.com/v1 ' ;
725
+ var expectedBaseUrl = 'pubsub.googleapis.com' ;
726
726
assert . strictEqual ( pubsub . baseUrl , expectedBaseUrl ) ;
727
727
} ) ;
728
728
729
729
it ( 'should remove slashes from the baseUrl' , function ( ) {
730
- var expectedBaseUrl = 'http:// localhost:8080' ;
730
+ var expectedBaseUrl = 'localhost:8080' ;
731
731
732
- setHost ( 'http:// localhost:8080/' ) ;
732
+ setHost ( 'localhost:8080/' ) ;
733
733
pubsub . determineBaseUrl_ ( ) ;
734
734
assert . strictEqual ( pubsub . baseUrl , expectedBaseUrl ) ;
735
735
736
- setHost ( 'http:// localhost:8080//' ) ;
736
+ setHost ( 'localhost:8080//' ) ;
737
737
pubsub . determineBaseUrl_ ( ) ;
738
738
assert . strictEqual ( pubsub . baseUrl , expectedBaseUrl ) ;
739
739
} ) ;
740
740
741
- it ( 'should default to http if protocol is unspecified' , function ( ) {
742
- setHost ( 'localhost:8080' ) ;
741
+ it ( 'should remove the protocol if specified' , function ( ) {
742
+ setHost ( 'http://localhost:8080' ) ;
743
+ pubsub . determineBaseUrl_ ( ) ;
744
+ assert . strictEqual ( pubsub . baseUrl , 'localhost:8080' ) ;
745
+
746
+ setHost ( 'https://localhost:8080' ) ;
743
747
pubsub . determineBaseUrl_ ( ) ;
744
- assert . strictEqual ( pubsub . baseUrl , 'http:// localhost:8080' ) ;
748
+ assert . strictEqual ( pubsub . baseUrl , 'localhost:8080' ) ;
745
749
} ) ;
746
750
747
751
it ( 'should not set customEndpoint when using default endpoint' , function ( ) {
@@ -751,7 +755,7 @@ describe('PubSub', function() {
751
755
} ) ;
752
756
753
757
describe ( 'with PUBSUB_EMULATOR_HOST environment variable' , function ( ) {
754
- var PUBSUB_EMULATOR_HOST = 'http:// localhost:9090' ;
758
+ var PUBSUB_EMULATOR_HOST = 'localhost:9090' ;
755
759
756
760
beforeEach ( function ( ) {
757
761
setHost ( PUBSUB_EMULATOR_HOST ) ;
0 commit comments