Skip to content

Commit 4ebe2fa

Browse files
authored
Name anonymous struct types in azidentity tests (Azure#23548)
1 parent 109f5f8 commit 4ebe2fa

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

sdk/azidentity/client_assertion_credential_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import (
1818
)
1919

2020
func TestClientAssertionCredential(t *testing.T) {
21-
key := struct{}{}
21+
type key struct{}
2222
calls := 0
2323
getAssertion := func(c context.Context) (string, error) {
24-
if v := c.Value(key); v == nil || !v.(bool) {
24+
if v := c.Value(key{}); v == nil || !v.(bool) {
2525
t.Fatal("unexpected context in getAssertion")
2626
}
2727
calls++
@@ -33,7 +33,7 @@ func TestClientAssertionCredential(t *testing.T) {
3333
if err != nil {
3434
t.Fatal(err)
3535
}
36-
ctx := context.WithValue(context.Background(), key, true)
36+
ctx := context.WithValue(context.Background(), key{}, true)
3737
_, err = cred.GetToken(ctx, testTRO)
3838
if err != nil {
3939
t.Fatal(err)

sdk/azidentity/device_code_credential_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func TestDeviceCodeCredential_GetTokenInvalidCredentials(t *testing.T) {
2929
}
3030

3131
func TestDeviceCodeCredential_UserPromptError(t *testing.T) {
32-
expectedCtx := context.WithValue(context.Background(), struct{}{}, "")
32+
type key struct{}
33+
expectedCtx := context.WithValue(context.Background(), key{}, "")
3334
expected := DeviceCodeMessage{UserCode: "user code", VerificationURL: "http://localhost", Message: "message"}
3435
success := "it worked"
3536
options := DeviceCodeCredentialOptions{

sdk/azidentity/on_behalf_of_credential_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ func TestOnBehalfOfCredential(t *testing.T) {
7474
},
7575
} {
7676
t.Run(test.name, func(t *testing.T) {
77-
key := struct{}{}
78-
ctx := context.WithValue(context.Background(), key, true)
77+
type key struct{}
78+
ctx := context.WithValue(context.Background(), key{}, true)
7979
srv := mockSTS{tokenRequestCallback: func(r *http.Request) *http.Response {
8080
if c := r.Context(); c == nil {
8181
t.Fatal("AcquireTokenOnBehalfOf received no Context")
82-
} else if v := c.Value(key); v == nil || !v.(bool) {
82+
} else if v := c.Value(key{}); v == nil || !v.(bool) {
8383
t.Fatal("AcquireTokenOnBehalfOf received unexpected Context")
8484
}
8585
if err := r.ParseForm(); err != nil {

0 commit comments

Comments
 (0)