Remediate all lint findings under the canonical golangci-lint config
Fix every finding surfaced by the canonical .golangci.yml with golangci-lint v2.12.2 (refs #61), behavior-preserving throughout: - err113: dynamic errors replaced with package-level sentinels and %w wrapping; direct comparisons converted to errors.Is - goprintffuncname: printf-style helpers renamed with an f suffix (ui.Writer message methods, cli.ReportErrorf, database.Fatalf, vaultik stdoutf) and all call sites updated - revive: stuttering type names renamed (blob.Handler, blob.WithReader, blob.ChunkPosition, storage.URL, storage.Info), doc comments added, unused parameters blanked, package comments added - contextcheck/noctx: ctx threaded through blob.Packer (AddChunk/Flush/FinalizeBlob/PackChunks) and scanner call sites; context-aware exec and sql variants used - funlen/cyclop/gocognit/nestif/dupl: oversized or duplicated functions split into focused helpers across production and test code - paralleltest/tparallel/thelper/usetesting/testpackage: tests parallelized where safe (global log.Initialize kept in the serial phase), helpers marked, t.TempDir adopted, external test packages where only exported API is used - gosec: integer conversions clamped or justified, header timeouts added, remaining findings suppressed with per-site justifications - mnd/goconst/lll/wsl_v5/nlreturn/noinlineerr/errcheck and other mechanical findings fixed directly Remove the deprecated log.LogOptions alias (callers migrated to log.Options). make check is green.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"sneak.berlin/go/vaultik/internal/s3"
|
||||
)
|
||||
|
||||
//nolint:paralleltest // test servers share a fixed localhost port
|
||||
func TestClient(t *testing.T) {
|
||||
ts := NewTestServer(t)
|
||||
defer func() {
|
||||
@@ -33,11 +34,21 @@ func TestClient(t *testing.T) {
|
||||
t.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
|
||||
// Test PutObject
|
||||
testKey := "foo/bar.txt"
|
||||
testData := []byte("test data")
|
||||
|
||||
err = client.PutObject(ctx, testKey, bytes.NewReader(testData))
|
||||
verifyPutGetHead(ctx, t, client, testKey, testData)
|
||||
verifyListAndDelete(ctx, t, client, testKey)
|
||||
}
|
||||
|
||||
// verifyPutGetHead uploads an object, reads it back, and checks existence.
|
||||
func verifyPutGetHead(
|
||||
ctx context.Context, t *testing.T, client *s3.Client,
|
||||
testKey string, testData []byte,
|
||||
) {
|
||||
t.Helper()
|
||||
|
||||
err := client.PutObject(ctx, testKey, bytes.NewReader(testData))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to put object: %v", err)
|
||||
}
|
||||
@@ -72,8 +83,15 @@ func TestClient(t *testing.T) {
|
||||
if !exists {
|
||||
t.Error("expected object to exist")
|
||||
}
|
||||
}
|
||||
|
||||
// verifyListAndDelete lists the object's prefix, deletes it, and checks
|
||||
// it is gone.
|
||||
func verifyListAndDelete(
|
||||
ctx context.Context, t *testing.T, client *s3.Client, testKey string,
|
||||
) {
|
||||
t.Helper()
|
||||
|
||||
// Test ListObjects
|
||||
keys, err := client.ListObjects(ctx, "foo/")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to list objects: %v", err)
|
||||
@@ -94,7 +112,7 @@ func TestClient(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify deletion
|
||||
exists, err = client.HeadObject(ctx, testKey)
|
||||
exists, err := client.HeadObject(ctx, testKey)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to head object after deletion: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user