@@ -19,6 +19,8 @@ func TestNewUnsafeResolver(t *testing.T) {
1919 wantResolvedGRPCEndpointAddress string
2020 wantResolvedGRPCEndpointError bool
2121 wantResolvedGRPCConnIsCustom bool
22+ wantResolvedEnableDirectPath bool
23+ wantResolvedEnableDirectPathXds bool
2224 }{
2325 {
2426 desc : "empty" ,
@@ -55,15 +57,30 @@ func TestNewUnsafeResolver(t *testing.T) {
5557 },
5658 wantResolvedGRPCConnIsCustom : true ,
5759 },
60+ {
61+ desc : "direct path plain" ,
62+ opts : []option.ClientOption {
63+ EnableDirectPath (true ),
64+ },
65+ wantResolvedEnableDirectPath : true ,
66+ },
67+ {
68+ desc : "direct path xds" ,
69+ opts : []option.ClientOption {
70+ EnableDirectPath (true ),
71+ EnableDirectPathXds (),
72+ },
73+ wantResolvedEnableDirectPath : true ,
74+ wantResolvedEnableDirectPathXds : true ,
75+ },
5876 } {
5977 t .Run (tc .desc , func (t * testing.T ) {
6078 ur , err := NewUnsafeResolver (tc .opts ... )
6179 if err != nil {
6280 t .Fatalf ("NewUnsafeResolver errored: %v" , err )
6381 }
6482 // check ResolvedGRPCConnPoolSize
65- got := ur .ResolvedGRPCConnPoolSize ()
66- if got != tc .wantResolvedGRPCConnPoolSize {
83+ if got := ur .ResolvedGRPCConnPoolSize (); got != tc .wantResolvedGRPCConnPoolSize {
6784 t .Errorf ("ResolveGRPCConnPoolSize: got %d, want %d" , got , tc .wantResolvedGRPCConnPoolSize )
6885 }
6986 // check ResolvedGRPCEndpoint
@@ -81,9 +98,15 @@ func TestNewUnsafeResolver(t *testing.T) {
8198 t .Errorf ("ResolvedGRPCEndpoint: address mismatch, got %q want %q" , gotAddr , tc .wantResolvedGRPCEndpointAddress )
8299 }
83100 // check ResolvedGRPCConnIsCustom
84- gotCustom := ur .ResolvedGRPCConnIsCustom ()
85- if gotCustom != tc .wantResolvedGRPCConnIsCustom {
86- t .Errorf ("ResolvedGRPCConnIsCustom: got %T want %T" , gotCustom , tc .wantResolvedGRPCConnIsCustom )
101+ if gotCustom := ur .ResolvedGRPCConnIsCustom (); gotCustom != tc .wantResolvedGRPCConnIsCustom {
102+ t .Errorf ("ResolvedGRPCConnIsCustom: got %t want %t" , gotCustom , tc .wantResolvedGRPCConnIsCustom )
103+ }
104+ // check ResolvedGRPCConnIsCustom
105+ if gotDirectPath := ur .ResolvedEnableDirectPath (); gotDirectPath != tc .wantResolvedEnableDirectPath {
106+ t .Errorf ("ResolvedEnableDirectPath: got %t want %t" , gotDirectPath , tc .wantResolvedEnableDirectPath )
107+ }
108+ if gotDirectPathXds := ur .ResolvedEnableDirectPathXds (); gotDirectPathXds != tc .wantResolvedEnableDirectPathXds {
109+ t .Errorf ("ResolvedEnableDirectPathXds: got %t want %t" , gotDirectPathXds , tc .wantResolvedEnableDirectPathXds )
87110 }
88111 })
89112 }
0 commit comments