Skip to content

Commit

Permalink
test(spanner): fix test case using reflection (#4169)
Browse files Browse the repository at this point in the history
The refactoring of the generated gapic client had broken a test case
that used reflection to get an internal value. This fixes the test
by first getting the (new) internalClient, and then getting the value
from the internal client.

Fixes #4156
  • Loading branch information
olavloite committed May 25, 2021
1 parent 825ddd6 commit 8bd87cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spanner/session_test.go
Expand Up @@ -1978,7 +1978,8 @@ func getSessionsPerChannel(sp *sessionPool) map[string]int {
// Get the pointer to the actual underlying gRPC ClientConn and use
// that as the key in the map.
val := reflect.ValueOf(s.client).Elem()
connPool := val.FieldByName("connPool").Elem().Elem()
internalClient := val.FieldByName("internalClient").Elem().Elem()
connPool := internalClient.FieldByName("connPool").Elem().Elem()
conn := connPool.Field(0).Pointer()
key := fmt.Sprintf("%v", conn)
sessionsPerChannel[key] = sessionsPerChannel[key] + 1
Expand Down

0 comments on commit 8bd87cb

Please sign in to comment.