cloudfront: use consistent names for test-tables, t.Parallel()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-30 15:30:32 +02:00
parent 5301ae14bf
commit f03d966ef7
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -261,6 +261,7 @@ func TestUpdateCalledRegularly(t *testing.T) {
} }
func TestEligibleForS3(t *testing.T) { func TestEligibleForS3(t *testing.T) {
t.Parallel()
ips := &awsIPs{ ips := &awsIPs{
ipv4: []net.IPNet{{ ipv4: []net.IPNet{{
IP: net.ParseIP("192.168.1.1"), IP: net.ParseIP("192.168.1.1"),
@ -277,7 +278,7 @@ func TestEligibleForS3(t *testing.T) {
return dcontext.WithRequest(empty, req) return dcontext.WithRequest(empty, req)
} }
cases := []struct { tests := []struct {
Context context.Context Context context.Context
Expected bool Expected bool
}{ }{
@ -286,16 +287,17 @@ func TestEligibleForS3(t *testing.T) {
{Context: makeContext("192.168.0.2"), Expected: false}, {Context: makeContext("192.168.0.2"), Expected: false},
} }
for _, testCase := range cases { for _, tc := range tests {
name := fmt.Sprintf("Client IP = %v", tc := tc
testCase.Context.Value("http.request.ip")) t.Run(fmt.Sprintf("Client IP = %v", tc.Context.Value("http.request.ip")), func(t *testing.T) {
t.Run(name, func(t *testing.T) { t.Parallel()
assertEqual(t, testCase.Expected, eligibleForS3(testCase.Context, ips)) assertEqual(t, tc.Expected, eligibleForS3(tc.Context, ips))
}) })
} }
} }
func TestEligibleForS3WithAWSIPNotInitialized(t *testing.T) { func TestEligibleForS3WithAWSIPNotInitialized(t *testing.T) {
t.Parallel()
ips := &awsIPs{ ips := &awsIPs{
ipv4: []net.IPNet{{ ipv4: []net.IPNet{{
IP: net.ParseIP("192.168.1.1"), IP: net.ParseIP("192.168.1.1"),
@ -312,7 +314,7 @@ func TestEligibleForS3WithAWSIPNotInitialized(t *testing.T) {
return dcontext.WithRequest(empty, req) return dcontext.WithRequest(empty, req)
} }
cases := []struct { tests := []struct {
Context context.Context Context context.Context
Expected bool Expected bool
}{ }{
@ -321,11 +323,11 @@ func TestEligibleForS3WithAWSIPNotInitialized(t *testing.T) {
{Context: makeContext("192.168.0.2"), Expected: false}, {Context: makeContext("192.168.0.2"), Expected: false},
} }
for _, testCase := range cases { for _, tc := range tests {
name := fmt.Sprintf("Client IP = %v", tc := tc
testCase.Context.Value("http.request.ip")) t.Run(fmt.Sprintf("Client IP = %v", tc.Context.Value("http.request.ip")), func(t *testing.T) {
t.Run(name, func(t *testing.T) { t.Parallel()
assertEqual(t, testCase.Expected, eligibleForS3(testCase.Context, ips)) assertEqual(t, tc.Expected, eligibleForS3(tc.Context, ips))
}) })
} }
} }