From e3964cf2b51085f71e33e773f3e6f21acf94b8c6 Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Tue, 5 Nov 2024 14:47:34 -0500 Subject: [PATCH 1/3] fix potential for lang mismatch in user agent tests --- aws/middleware/user_agent_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aws/middleware/user_agent_test.go b/aws/middleware/user_agent_test.go index 95f7fbc60cf..84620364eb3 100644 --- a/aws/middleware/user_agent_test.go +++ b/aws/middleware/user_agent_test.go @@ -15,7 +15,11 @@ import ( smithyhttp "github.com/aws/smithy-go/transport/http" ) -var expectedAgent = aws.SDKName + "/" + aws.SDKVersion + " os/" + getNormalizedOSName() + " lang/go#" + languageVersion + " md/GOOS#" + runtime.GOOS + " md/GOARCH#" + runtime.GOARCH +var expectedAgent = aws.SDKName + "/" + aws.SDKVersion + + " os/" + getNormalizedOSName() + + " lang/go#" + strings.Map(rules, languageVersion) + // normalize as the user-agent builder will + " md/GOOS#" + runtime.GOOS + + " md/GOARCH#" + runtime.GOARCH func TestRequestUserAgent_HandleBuild(t *testing.T) { cases := map[string]struct { From 15752d0a3fcdff0770107ed0e66daa252dbab9e2 Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Tue, 5 Nov 2024 14:48:07 -0500 Subject: [PATCH 2/3] changelog --- .changelog/23e49414655246ba97c2d1991c0daf67.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changelog/23e49414655246ba97c2d1991c0daf67.json diff --git a/.changelog/23e49414655246ba97c2d1991c0daf67.json b/.changelog/23e49414655246ba97c2d1991c0daf67.json new file mode 100644 index 00000000000..b87c97b6970 --- /dev/null +++ b/.changelog/23e49414655246ba97c2d1991c0daf67.json @@ -0,0 +1,8 @@ +{ + "id": "23e49414-6552-46ba-97c2-d1991c0daf67", + "type": "bugfix", + "description": "Fix potential for user agent language mismatch in tests.", + "modules": [ + "." + ] +} \ No newline at end of file From 0f689b4b21e91ab9edd58efcf9ddc94e8a04d280 Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Tue, 5 Nov 2024 15:42:41 -0500 Subject: [PATCH 3/3] make mismatch error clearer --- aws/middleware/user_agent_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aws/middleware/user_agent_test.go b/aws/middleware/user_agent_test.go index 84620364eb3..12f7bcb43ae 100644 --- a/aws/middleware/user_agent_test.go +++ b/aws/middleware/user_agent_test.go @@ -176,7 +176,7 @@ func TestAddUserAgentKey(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -229,7 +229,7 @@ func TestAddUserAgentKeyValue(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -294,7 +294,7 @@ func TestAddUserAgentFeature(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Errorf("User-Agent did not match expected, %v != %v", c.Expect, ua[0]) + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -347,7 +347,7 @@ func TestAddSDKAgentKey(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -403,7 +403,7 @@ func TestAddSDKAgentKeyValue(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -450,7 +450,7 @@ func TestAddUserAgentKey_AddToStack(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) } @@ -500,7 +500,7 @@ func TestAddUserAgentKeyValue_AddToStack(t *testing.T) { t.Fatalf("expect User-Agent to be present") } if ua[0] != c.Expect { - t.Error("User-Agent did not match expected") + t.Errorf("User-Agent: %q != %q", c.Expect, ua[0]) } }) }