From 82897becacb0c658ac8eec09c7e2929f9bfdd0fb Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:56:54 -0500 Subject: [PATCH] fix potential for user-agent lang value mismatch in tests (#2888) --- .../23e49414655246ba97c2d1991c0daf67.json | 8 ++++++++ aws/middleware/user_agent_test.go | 20 +++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) 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 diff --git a/aws/middleware/user_agent_test.go b/aws/middleware/user_agent_test.go index 95f7fbc60cf..12f7bcb43ae 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 { @@ -172,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]) } }) } @@ -225,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]) } }) } @@ -290,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]) } }) } @@ -343,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]) } }) } @@ -399,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]) } }) } @@ -446,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]) } }) } @@ -496,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]) } }) }