Skip to content

Commit

Permalink
fix potential for user-agent lang value mismatch in tests (#2888)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored Nov 6, 2024
1 parent 061540b commit 82897be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
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

0 comments on commit 82897be

Please sign in to comment.