Skip to content

Commit

Permalink
test(storage): fix go vet for test errors (#11299)
Browse files Browse the repository at this point in the history
Calling t.Errorf without a proper format string causes an error in go 1.24.
  • Loading branch information
tritone authored Dec 17, 2024
1 parent 9724361 commit 2f99c97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
48 changes: 24 additions & 24 deletions storage/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set BucketPolicyOnly.Enabled = true --> UBLA should be set to enabled in
Expand All @@ -294,7 +294,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set both BucketPolicyOnly.Enabled = true and
Expand All @@ -310,7 +310,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set UBLA.Enabled=false and BucketPolicyOnly.Enabled=false --> UBLA
Expand All @@ -322,7 +322,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting PublicAccessPrevention to "unspecified" leads to the
Expand All @@ -333,7 +333,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting PublicAccessPrevention to "inherited" leads to the
Expand All @@ -344,15 +344,15 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting RPO to default is propagated in the proto.
attrs.RPO = RPODefault
got = attrs.toRawBucket()
want.Rpo = rpoDefault
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Re-enable UBLA and confirm that it does not affect the PAP setting.
Expand All @@ -365,7 +365,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Disable UBLA and reset PAP to default. Confirm that the IAM config is set
Expand All @@ -375,7 +375,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
got = attrs.toRawBucket()
want.IamConfiguration = nil
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}
}

Expand Down Expand Up @@ -504,7 +504,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set BucketPolicyOnly.Enabled = true --> UBLA should be set to enabled in
Expand All @@ -522,7 +522,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set both BucketPolicyOnly.Enabled = true and
Expand All @@ -542,7 +542,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set UBLA.Enabled=false and BucketPolicyOnly.Enabled=false --> UBLA
Expand All @@ -561,7 +561,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// UBLA.Enabled will have precedence above BucketPolicyOnly.Enabled if both
Expand All @@ -580,7 +580,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set an empty Lifecycle and verify that it will be sent.
Expand All @@ -595,7 +595,7 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
ForceSendFields: []string{"Lifecycle"},
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}
}

Expand Down Expand Up @@ -992,7 +992,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set BucketPolicyOnly.Enabled = true --> UBLA should be set to enabled in
Expand All @@ -1007,7 +1007,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set both BucketPolicyOnly.Enabled = true and
Expand All @@ -1023,7 +1023,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Set UBLA.Enabled=false and BucketPolicyOnly.Enabled=false --> UBLA
Expand All @@ -1035,7 +1035,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "enforced",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting PublicAccessPrevention to "unspecified" leads to the
Expand All @@ -1046,7 +1046,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting PublicAccessPrevention to "inherited" leads to the
Expand All @@ -1057,15 +1057,15 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Test that setting RPO to default is propagated in the proto.
attrs.RPO = RPODefault
got = attrs.toProtoBucket()
want.Rpo = rpoDefault
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Re-enable UBLA and confirm that it does not affect the PAP setting.
Expand All @@ -1078,7 +1078,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
PublicAccessPrevention: "inherited",
}
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}

// Disable UBLA and reset PAP to default. Confirm that the IAM config is set
Expand All @@ -1088,7 +1088,7 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
got = attrs.toProtoBucket()
want.IamConfig = nil
if msg := testutil.Diff(got, want); msg != "" {
t.Errorf(msg)
t.Errorf("%v", msg)
}
}

Expand Down
3 changes: 2 additions & 1 deletion storage/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func TestApplyStorageOpt(t *testing.T) {
}
}
if !cmp.Equal(got, test.want, cmp.AllowUnexported(storageConfig{}, experimental.ReadStallTimeoutConfig{})) {
t.Errorf(cmp.Diff(got, test.want, cmp.AllowUnexported(storageConfig{}, experimental.ReadStallTimeoutConfig{})))
diff := cmp.Diff(got, test.want, cmp.AllowUnexported(storageConfig{}, experimental.ReadStallTimeoutConfig{}))
t.Errorf("options: diff got, want: %v", diff)
}
})
}
Expand Down

0 comments on commit 2f99c97

Please sign in to comment.