test(b2): add test seams for account-info cleanup, file sync and buffer pool return

Aperta
#246 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ffumero2003 ci sta già lavorando.

Dal 30/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

testing

Context

The #204 test-integrity work pinned most of the b2 production edges that mutation testing found, but three can't be tested without a small test hook in production code. A test-only change can't cover them:

  • b2/accountinfo.go:135, temp-file cleanup: when writing the session file, the deferred os.Remove of the temporary file can fail, and that error handling isn't tested. A test can't make the removal fail at that exact point; making the directory read-only beforehand makes os.CreateTemp fail instead.
  • b2/accountinfo.go:146, file.Sync(): nothing checks that the session file is synced before it's renamed into place. Skipping Sync passes every test.
  • b2/buffer.go:148, buffer pool return: memoryBuffer.Close returns its buffer to bufpool. Double-Close is now tested (#204 slice C3), but returning the buffer to the pool is not: sync.Pool.Get may drop a value that was just put, so a test can't observe the Put.

Acceptance criteria

  • R1. For each of the three: a test that fails when the behavior is broken (the cleanup error is ignored, Sync is skipped, the buffer isn't returned to the pool), recorded with its break.
  • R2. No exported API change; default behavior unchanged.
  • R3. Changelog: not needed (no user-visible change), so skip-changelog.

In scope

Proposed approach

Add the smallest unexported seam for each, and keep the public API unchanged:

  • an unexported hook (or file-operations interface) in accountinfo.go that tests can replace, so Remove can fail and Sync can be observed;
  • an unexported pool variable or interface in buffer.go that tests can replace with a recording pool.

Out of scope

  • Unrelated work outside the components and behavior described in In scope.

Verification

Run the repository regression checks with live credentials unset:

unset B2_APPLICATION_KEY_ID B2_APPLICATION_KEY B2_ACCOUNT_ID B2_ACCOUNT_KEY
go build ./...
go vet ./...
go test -race -count=1 ./b2
  • For each seam, independently break the stated behavior: ignore cleanup failure, omit Sync, or omit pool return. Record the targeted failing test, then restore and record green.
  • Verify the default implementations and exported API remain unchanged; retain the original skip-changelog treatment.
  • Expected result: the checks above succeed and the observable outcomes in Acceptance criteria are demonstrated. If a check cannot run, report Could not run because: ...; if it starts but fails, report Could not complete because: .... A skipped check is not a pass.

Links

  • Part of the #204 checklist (items accountinfo.go:135, accountinfo.go:146, buffer.go:148), stopped in slice C3 because they need these seams.
Lingua principale
Go
Stelle
66
Fork
18
Merge medio
1g 10h
PR unite (30g)
132

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Backblaze/blazer

Tutte le issue di Backblaze/blazer

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.