zeroshade commented on code in PR #1584:
URL: https://github.com/apache/iceberg-go/pull/1584#discussion_r3732157731


##########
io/gocloud/gcs_test.go:
##########
@@ -142,6 +144,40 @@ func TestGCSCredentialsNoAuth(t *testing.T) {
        assert.Nil(t, creds)
 }
 
+func TestGCSCredentialsPropagatesADCError(t *testing.T) {
+       t.Run("missing configured file", func(t *testing.T) {
+               t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", 
filepath.Join(t.TempDir(), "missing.json"))
+
+               creds, err := gcsCredentials(context.Background(), nil)
+               require.ErrorContains(t, err, "gcs: no credentials found")
+               require.ErrorContains(t, err, io.GCSNoAuth)
+               assert.Nil(t, creds)
+       })
+
+       t.Run("no configured credentials", func(t *testing.T) {
+               t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "")
+
+               creds, err := gcsCredentialsWithDefault(context.Background(), 
nil,
+                       func(context.Context) (*google.Credentials, error) {
+                               return nil, errors.New("application default 
credentials unavailable")
+                       })
+               require.ErrorContains(t, err, "gcs: no credentials found")
+               require.ErrorContains(t, err, io.GCSNoAuth)
+               assert.Nil(t, creds)
+       })
+
+       t.Run("nil credentials", func(t *testing.T) {
+               creds, err := gcsCredentialsWithDefault(context.Background(), 
nil,
+                       func(context.Context) (*google.Credentials, error) { 
return nil, nil })
+               require.ErrorContains(t, err, "gcs: no credentials found")
+               assert.Nil(t, creds)
+       })
+
+       creds, err := gcsCredentials(context.Background(), 
map[string]string{io.GCSNoAuth: "true"})

Review Comment:
   Non-blocking: this repeats the existing `TestGCSCredentialsNoAuth` 
assertion. Consider calling `gcsCredentialsWithDefault` here with 
`gcs.no-auth=true` and a `defaultCredentials` function that panics; that would 
prove the anonymous path short-circuits ADC lookup, which is the more valuable 
inverse property.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to