@@ -9,14 +9,15 @@ import (
99
1010func TestIdentityTransport_CapturesGotrueIdHeader (t * testing.T ) {
1111 var captured string
12+ cb := func (id string ) { captured = id }
1213 transport := & identityTransport {
1314 RoundTripper : roundTripFunc (func (req * http.Request ) (* http.Response , error ) {
1415 return & http.Response {
1516 StatusCode : 200 ,
1617 Header : http.Header {"X-Gotrue-Id" : []string {"user-abc-123" }},
1718 }, nil
1819 }),
19- onGotrueID : func ( id string ) { captured = id } ,
20+ onGotrueID : & cb ,
2021 }
2122 req , _ := http .NewRequest ("GET" , "https://api.supabase.io/v1/projects" , nil )
2223 resp , err := transport .RoundTrip (req )
@@ -27,14 +28,15 @@ func TestIdentityTransport_CapturesGotrueIdHeader(t *testing.T) {
2728
2829func TestIdentityTransport_IgnoresWhenHeaderMissing (t * testing.T ) {
2930 var captured string
31+ cb := func (id string ) { captured = id }
3032 transport := & identityTransport {
3133 RoundTripper : roundTripFunc (func (req * http.Request ) (* http.Response , error ) {
3234 return & http.Response {
3335 StatusCode : 200 ,
3436 Header : http.Header {},
3537 }, nil
3638 }),
37- onGotrueID : func ( id string ) { captured = id } ,
39+ onGotrueID : & cb ,
3840 }
3941 req , _ := http .NewRequest ("GET" , "https://api.supabase.io/v1/projects" , nil )
4042 _ , err := transport .RoundTrip (req )
@@ -58,13 +60,31 @@ func TestIdentityTransport_NilCallbackDoesNotPanic(t *testing.T) {
5860 assert .Equal (t , 200 , resp .StatusCode )
5961}
6062
63+ func TestIdentityTransport_NilFuncBehindPointerDoesNotPanic (t * testing.T ) {
64+ var cb func (string ) // nil func
65+ transport := & identityTransport {
66+ RoundTripper : roundTripFunc (func (req * http.Request ) (* http.Response , error ) {
67+ return & http.Response {
68+ StatusCode : 200 ,
69+ Header : http.Header {"X-Gotrue-Id" : []string {"user-abc-123" }},
70+ }, nil
71+ }),
72+ onGotrueID : & cb ,
73+ }
74+ req , _ := http .NewRequest ("GET" , "https://api.supabase.io/v1/projects" , nil )
75+ resp , err := transport .RoundTrip (req )
76+ assert .NoError (t , err )
77+ assert .Equal (t , 200 , resp .StatusCode )
78+ }
79+
6180func TestIdentityTransport_InnerTransportError (t * testing.T ) {
6281 var captured string
82+ cb := func (id string ) { captured = id }
6383 transport := & identityTransport {
6484 RoundTripper : roundTripFunc (func (req * http.Request ) (* http.Response , error ) {
6585 return nil , assert .AnError
6686 }),
67- onGotrueID : func ( id string ) { captured = id } ,
87+ onGotrueID : & cb ,
6888 }
6989 req , _ := http .NewRequest ("GET" , "https://api.supabase.io/v1/projects" , nil )
7090 resp , err := transport .RoundTrip (req )
0 commit comments