Skip to content

Commit 82897be

Browse files
authored
fix potential for user-agent lang value mismatch in tests (#2888)
1 parent 061540b commit 82897be

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "23e49414-6552-46ba-97c2-d1991c0daf67",
3+
"type": "bugfix",
4+
"description": "Fix potential for user agent language mismatch in tests.",
5+
"modules": [
6+
"."
7+
]
8+
}

aws/middleware/user_agent_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import (
1515
smithyhttp "github.com/aws/smithy-go/transport/http"
1616
)
1717

18-
var expectedAgent = aws.SDKName + "/" + aws.SDKVersion + " os/" + getNormalizedOSName() + " lang/go#" + languageVersion + " md/GOOS#" + runtime.GOOS + " md/GOARCH#" + runtime.GOARCH
18+
var expectedAgent = aws.SDKName + "/" + aws.SDKVersion +
19+
" os/" + getNormalizedOSName() +
20+
" lang/go#" + strings.Map(rules, languageVersion) + // normalize as the user-agent builder will
21+
" md/GOOS#" + runtime.GOOS +
22+
" md/GOARCH#" + runtime.GOARCH
1923

2024
func TestRequestUserAgent_HandleBuild(t *testing.T) {
2125
cases := map[string]struct {
@@ -172,7 +176,7 @@ func TestAddUserAgentKey(t *testing.T) {
172176
t.Fatalf("expect User-Agent to be present")
173177
}
174178
if ua[0] != c.Expect {
175-
t.Error("User-Agent did not match expected")
179+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
176180
}
177181
})
178182
}
@@ -225,7 +229,7 @@ func TestAddUserAgentKeyValue(t *testing.T) {
225229
t.Fatalf("expect User-Agent to be present")
226230
}
227231
if ua[0] != c.Expect {
228-
t.Error("User-Agent did not match expected")
232+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
229233
}
230234
})
231235
}
@@ -290,7 +294,7 @@ func TestAddUserAgentFeature(t *testing.T) {
290294
t.Fatalf("expect User-Agent to be present")
291295
}
292296
if ua[0] != c.Expect {
293-
t.Errorf("User-Agent did not match expected, %v != %v", c.Expect, ua[0])
297+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
294298
}
295299
})
296300
}
@@ -343,7 +347,7 @@ func TestAddSDKAgentKey(t *testing.T) {
343347
t.Fatalf("expect User-Agent to be present")
344348
}
345349
if ua[0] != c.Expect {
346-
t.Error("User-Agent did not match expected")
350+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
347351
}
348352
})
349353
}
@@ -399,7 +403,7 @@ func TestAddSDKAgentKeyValue(t *testing.T) {
399403
t.Fatalf("expect User-Agent to be present")
400404
}
401405
if ua[0] != c.Expect {
402-
t.Error("User-Agent did not match expected")
406+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
403407
}
404408
})
405409
}
@@ -446,7 +450,7 @@ func TestAddUserAgentKey_AddToStack(t *testing.T) {
446450
t.Fatalf("expect User-Agent to be present")
447451
}
448452
if ua[0] != c.Expect {
449-
t.Error("User-Agent did not match expected")
453+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
450454
}
451455
})
452456
}
@@ -496,7 +500,7 @@ func TestAddUserAgentKeyValue_AddToStack(t *testing.T) {
496500
t.Fatalf("expect User-Agent to be present")
497501
}
498502
if ua[0] != c.Expect {
499-
t.Error("User-Agent did not match expected")
503+
t.Errorf("User-Agent: %q != %q", c.Expect, ua[0])
500504
}
501505
})
502506
}

0 commit comments

Comments
 (0)