@@ -338,7 +338,7 @@ func TestClient_Nearest(t *testing.T) {
338338 if tt .cl == nil {
339339 tt .cl = clientgeo .NewAppEngineLocator ()
340340 }
341- c := NewClient (tt .project , tt .signer , tt .locator , tt .cl , prom .NewAPI (nil ), tt .limits , tt .ipLimiter )
341+ c := NewClient (tt .project , tt .signer , tt .locator , tt .cl , prom .NewAPI (nil ), tt .limits , tt .ipLimiter , nil )
342342
343343 mux := http .NewServeMux ()
344344 mux .HandleFunc ("/v2/nearest/" , c .Nearest )
@@ -417,7 +417,7 @@ func TestClient_Ready(t *testing.T) {
417417 }
418418 for _ , tt := range tests {
419419 t .Run (tt .name , func (t * testing.T ) {
420- c := NewClient ("foo" , & fakeSigner {}, & fakeLocatorV2 {StatusTracker : & heartbeattest.FakeStatusTracker {Err : tt .fakeErr }}, nil , nil , nil , nil )
420+ c := NewClient ("foo" , & fakeSigner {}, & fakeLocatorV2 {StatusTracker : & heartbeattest.FakeStatusTracker {Err : tt .fakeErr }}, nil , nil , nil , nil , nil )
421421
422422 mux := http .NewServeMux ()
423423 mux .HandleFunc ("/ready/" , c .Ready )
@@ -475,7 +475,7 @@ func TestClient_Registrations(t *testing.T) {
475475 }
476476
477477 t .Run (tt .name , func (t * testing.T ) {
478- c := NewClient ("foo" , & fakeSigner {}, & fakeLocatorV2 {StatusTracker : fakeStatusTracker }, nil , nil , nil , nil )
478+ c := NewClient ("foo" , & fakeSigner {}, & fakeLocatorV2 {StatusTracker : fakeStatusTracker }, nil , nil , nil , nil , nil )
479479
480480 mux := http .NewServeMux ()
481481 mux .HandleFunc ("/v2/siteinfo/registrations/" , c .Registrations )
@@ -499,6 +499,7 @@ func TestExtraParams(t *testing.T) {
499499 hostname string
500500 index int
501501 p paramOpts
502+ client * Client
502503 earlyExitProbability float64
503504 want url.Values
504505 }{
@@ -512,13 +513,55 @@ func TestExtraParams(t *testing.T) {
512513 ranks : map [string ]int {"host" : 0 },
513514 svcParams : map [string ]float64 {},
514515 },
516+ client : & Client {},
515517 want : url.Values {
516518 "client_name" : []string {"client" },
517519 "locate_version" : []string {"v2" },
518520 "metro_rank" : []string {"0" },
519521 "index" : []string {"0" },
520522 },
521523 },
524+ {
525+ name : "early-exit-client-match" ,
526+ hostname : "host" ,
527+ index : 0 ,
528+ p : paramOpts {
529+ raw : map [string ][]string {"client_name" : {"foo" }},
530+ version : "v2" ,
531+ ranks : map [string ]int {"host" : 0 },
532+ svcParams : map [string ]float64 {},
533+ },
534+ client : & Client {
535+ earlyExitClients : map [string ]bool {"foo" : true },
536+ },
537+ want : url.Values {
538+ "client_name" : []string {"foo" },
539+ "locate_version" : []string {"v2" },
540+ "metro_rank" : []string {"0" },
541+ "index" : []string {"0" },
542+ "early_exit" : []string {"250" },
543+ },
544+ },
545+ {
546+ name : "early-exit-client-no-match" ,
547+ hostname : "host" ,
548+ index : 0 ,
549+ p : paramOpts {
550+ raw : map [string ][]string {"client_name" : {"bar" }},
551+ version : "v2" ,
552+ ranks : map [string ]int {"host" : 0 },
553+ svcParams : map [string ]float64 {},
554+ },
555+ client : & Client {
556+ earlyExitClients : map [string ]bool {"foo" : true },
557+ },
558+ want : url.Values {
559+ "client_name" : []string {"bar" },
560+ "locate_version" : []string {"v2" },
561+ "metro_rank" : []string {"0" },
562+ "index" : []string {"0" },
563+ },
564+ },
522565 {
523566 name : "no-client" ,
524567 hostname : "host" ,
@@ -626,7 +669,7 @@ func TestExtraParams(t *testing.T) {
626669 }
627670 for _ , tt := range tests {
628671 t .Run (tt .name , func (t * testing.T ) {
629- got := extraParams (tt .hostname , tt .index , tt .p )
672+ got := tt . client . extraParams (tt .hostname , tt .index , tt .p )
630673 if ! reflect .DeepEqual (got , tt .want ) {
631674 t .Errorf ("extraParams() = %v, want %v" , got , tt .want )
632675 }
0 commit comments