Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name anonymous struct types in azidentity tests #23548

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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