Let the integration tests run against a custom B2 endpoint (B2_REALM)

Aperta Adatta ai principianti
#273 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
testing

Direzione di ricerca

Inizia da base/integration_test.go e b2/integration_test.go, dove vengono lette le variabili d'ambiente (intorno alle righe 39-42), poi individua le 12 chiamate a AuthorizeAccount e NewClient elencate nell'issue. Leggi le opzioni SetAPIBase e APIBase in base/base.go e b2/b2.go. È completato quando B2_REALM reindirizza ogni chiamata in entrambi i file e, rimuovendola, il comportamento resta invariato. Per eseguire i test serve un simulatore B2 locale; chiedi ai maintainer come verificano la modifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What

Please let the integration tests in b2/integration_test.go and base/integration_test.go run against a custom B2 endpoint, selected by an optional environment variable (for example B2_REALM).

Why

The integration tests read only B2_APPLICATION_KEY_ID and B2_APPLICATION_KEY and never pass an endpoint option, so every call goes to https://api.backblazeb2.com and the tests need a real account. If they could target a local B2 API simulator, Backblaze's own CI or a contributor could run them without real-account credentials. The library already supports a custom endpoint; only the tests do not use it.

What I checked (default branch main)

  • Env vars read: base/integration_test.go:39-40,57-58 and b2/integration_test.go:39-42,718-719 (plus B2_TRANSIENT_ERRORS). Neither file references APIBase, SetAPIBase or any endpoint/realm variable.
  • Calls without an endpoint option: AuthorizeAccount(...) x6 in base/integration_test.go (for example lines 65, 449, 512, 558, 604, 774) and NewClient(...) x6 in b2/integration_test.go (for example lines 727, 803, 1176, 1205, 1282, 1600). That is 12 call sites in these two files.
  • The library options exist: base.SetAPIBase(url) (base/base.go:777), b2.APIBase(url) (b2/b2.go:150), b2.Transport(rt) (b2/b2.go:158); the default is base.APIBase (base/base.go:44).

Minimal sketch

Read the variable once per file and pass it through a helper, so each call site changes by one argument:

// b2/integration_test.go
func realmOpts() []ClientOption {
	if u := os.Getenv("B2_REALM"); u != "" {
		return []ClientOption{APIBase(u)}
	}
	return nil
}
// client, err := NewClient(ctx, id, key, realmOpts()...)

// base/integration_test.go: same idea with SetAPIBase(u) for AuthorizeAccount.

When B2_REALM is unset, behaviour is unchanged (production).

Acceptance criteria

  • With B2_REALM unset, the integration tests behave identically to today.
  • With B2_REALM=<base URL> set, every NewClient / AuthorizeAccount call in both files uses it and nothing reaches api.backblazeb2.com.
  • No change to non-test code.

Offer

The Backblaze SDK test-harness team can contribute this patch as a PR if that is welcome. We have not pushed any code.

🤖 Generated with Claude Code

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.