Skip to content

Commit

Permalink
Name anonymous struct types in azidentity tests (#23548)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored Oct 4, 2024
1 parent 109f5f8 commit 4ebe2fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions sdk/azidentity/client_assertion_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

func TestClientAssertionCredential(t *testing.T) {
key := struct{}{}
type key struct{}
calls := 0
getAssertion := func(c context.Context) (string, error) {
if v := c.Value(key); v == nil || !v.(bool) {
if v := c.Value(key{}); v == nil || !v.(bool) {
t.Fatal("unexpected context in getAssertion")
}
calls++
Expand All @@ -33,7 +33,7 @@ func TestClientAssertionCredential(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ctx := context.WithValue(context.Background(), key, true)
ctx := context.WithValue(context.Background(), key{}, true)
_, err = cred.GetToken(ctx, testTRO)
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion sdk/azidentity/device_code_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func TestDeviceCodeCredential_GetTokenInvalidCredentials(t *testing.T) {
}

func TestDeviceCodeCredential_UserPromptError(t *testing.T) {
expectedCtx := context.WithValue(context.Background(), struct{}{}, "")
type key struct{}
expectedCtx := context.WithValue(context.Background(), key{}, "")
expected := DeviceCodeMessage{UserCode: "user code", VerificationURL: "http://localhost", Message: "message"}
success := "it worked"
options := DeviceCodeCredentialOptions{
Expand Down
6 changes: 3 additions & 3 deletions sdk/azidentity/on_behalf_of_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ func TestOnBehalfOfCredential(t *testing.T) {
},
} {
t.Run(test.name, func(t *testing.T) {
key := struct{}{}
ctx := context.WithValue(context.Background(), key, true)
type key struct{}
ctx := context.WithValue(context.Background(), key{}, true)
srv := mockSTS{tokenRequestCallback: func(r *http.Request) *http.Response {
if c := r.Context(); c == nil {
t.Fatal("AcquireTokenOnBehalfOf received no Context")
} else if v := c.Value(key); v == nil || !v.(bool) {
} else if v := c.Value(key{}); v == nil || !v.(bool) {
t.Fatal("AcquireTokenOnBehalfOf received unexpected Context")
}
if err := r.ParseForm(); err != nil {
Expand Down

0 comments on commit 4ebe2fa

Please sign in to comment.