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

fix potential for user-agent lang value mismatch in tests #2888

Merged
merged 3 commits into from
Nov 6, 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
8 changes: 8 additions & 0 deletions .changelog/23e49414655246ba97c2d1991c0daf67.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "23e49414-6552-46ba-97c2-d1991c0daf67",
"type": "bugfix",
"description": "Fix potential for user agent language mismatch in tests.",
"modules": [
"."
]
}
20 changes: 12 additions & 8 deletions aws/middleware/user_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down Expand Up @@ -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])
}
})
}
Expand Down
Loading