History

test: make token fallback hermetic (#141)

Peter Steinberger committed 3 months ago

Commit befe0fc1 parent 16f71e911 files · +85 −64Browse files

Unified · Split

11 files
  1. internal/cli/app.go +5 −4
  2. internal/cli/app_test.go +22 −11
  3. internal/cli/cloud_commands_test.go +3 −3
  4. internal/cli/github_token.go +5 −1
  5. internal/cli/github_token_test.go +12 −16
  6. internal/cli/remote_commands_test.go +20 −11
  7. internal/config/config_test.go +12 −12
  8. internal/config/remote_token_test.go +2 −2
  9. internal/github/client_test.go +2 −2
  10. internal/openai/summaries_test.go +1 −1
  11. internal/store/sync_failures_test.go +1 −1
internal/cli/app.go+5−4
@@ -66,10 +66,11 @@ type App struct { · 65 unmodified lines
6666 Stdout io.Writer
6767 Stderr io.Writer
6868
69− configPath string
70− format OutputFormat
71− getWorkingDirectory func() (string, error)
72− dbTargetNoticeOnce sync.Once
69+ configPath string
70+ format OutputFormat
71+ getWorkingDirectory func() (string, error)
72+ githubAuthTokenLookup func(context.Context) (string, error)
73+ dbTargetNoticeOnce sync.Once
7374 }
7475
7576 type initResult struct {
internal/cli/app_test.go+22−11
@@ -2140,7 +2140,12 @@ func TestCloudPublishStageOnlyThenResumesDefaultCutover(t *testing.T) { · 2139 unmodified lines
21402140 stagedDatasetGeneratedAt = result.DatasetGeneratedAt
21412141 if stagedDatasetGeneratedAt != concurrentDatasetGeneratedAt ||
21422142 result.MutationToken != "" {
2143− t.Fatalf("stage-only did not bind its generation: %#v", result)
2143+ t.Fatalf(
2144+ "stage-only generation mismatch: generation_matches=%t mutation_token_present=%t mutation_token_length=%d",
2145+ stagedDatasetGeneratedAt == concurrentDatasetGeneratedAt,
2146+ result.MutationToken != "",
2147+ len(result.MutationToken),
2148+ )
21442149 }
21452150 time.Sleep(2 * time.Millisecond)
21462151 }
@@ -2161,7 +2166,7 @@ func TestCloudPublishStageOnlyThenResumesDefaultCutover(t *testing.T) { · 14 unmodified lines
21612166 )
21622167 }
21632168 if result.MutationToken != "" {
2164− t.Fatalf("resumed publish minted mutation token %q", result.MutationToken)
2169+ t.Fatalf("resumed publish minted mutation token: length=%d", len(result.MutationToken))
21652170 }
21662171 }
21672172 }
@@ -2389,7 +2394,13 @@ func TestRemoteLoginStoresKeyringToken(t *testing.T) { · 221 unmodified lines
23892394 t.Fatalf("remote login: %v", err)
23902395 }
23912396 if pollSecretHash == "" || pollSecret == "" || crawlremote.LoginPollSecretHash(pollSecret) != pollSecretHash {
2392− t.Fatalf("poll secret/hash not linked: secret=%q hash=%q", pollSecret, pollSecretHash)
2397+ t.Fatalf(
2398+ "poll secret/hash not linked: secret_present=%t secret_length=%d hash_present=%t hash_length=%d",
2399+ pollSecret != "",
2400+ len(pollSecret),
2401+ pollSecretHash != "",
2402+ len(pollSecretHash),
2403+ )
23932404 }
23942405 cfg, err := config.Load(configPath)
23952406 if err != nil {
@@ -2403,7 +2414,7 @@ func TestRemoteLoginStoresKeyringToken(t *testing.T) { · 7 unmodified lines
24032414 t.Fatalf("keyring get: %v", err)
24042415 }
24052416 if stored != "session-token" {
2406− t.Fatalf("stored token = %q", stored)
2417+ t.Fatalf("stored token mismatch: present=%t length=%d", stored != "", len(stored))
24072418 }
24082419
24092420 whoami := New()
@@ -2461,7 +2472,7 @@ func TestRemoteLoginWithGitHubTokenEnvStoresKeyringToken(t *testing.T) { · 51 unmodified lines
24612472 t.Fatalf("remote login: %v", err)
24622473 }
24632474 if sawToken != "github-token" {
2464− t.Fatalf("github token = %q", sawToken)
2475+ t.Fatalf("github token mismatch: present=%t length=%d", sawToken != "", len(sawToken))
24652476 }
24662477 if !strings.Contains(out.String(), `"login_method": "github-token"`) {
24672478 t.Fatalf("login output = %s", out.String())
@@ -2475,7 +2486,7 @@ func TestRemoteLoginWithGitHubTokenEnvStoresKeyringToken(t *testing.T) { · 7 unmodified lines
24752486 t.Fatalf("keyring get: %v", err)
24762487 }
24772488 if stored != "session-token" {
2478− t.Fatalf("stored token = %q", stored)
2489+ t.Fatalf("stored token mismatch: present=%t length=%d", stored != "", len(stored))
24792490 }
24802491
24812492 whoami := New()
@@ -2995,7 +3006,7 @@ func TestSameGitRemoteIgnoresHTTPSCredentials(t *testing.T) { · 513 unmodified lines
29953006 func TestGitRemoteForMessageRedactsURLCredentials(t *testing.T) {
29963007 got := gitRemoteForMessage("https://user:secret@example.com/org/store.git")
29973008 if strings.Contains(got, "user") || strings.Contains(got, "secret") {
2998− t.Fatalf("remote message leaked credentials: %q", got)
3009+ t.Fatal("remote message leaked credentials")
29993010 }
30003011 if got != "https://example.com/org/store.git" {
30013012 t.Fatalf("remote message = %q, want sanitized URL", got)
@@ -5840,7 +5851,7 @@ func TestCommandFlowCoversSearchEmbedNeighborsClusterDetailRunsAndRefresh(t *tes · 2838 unmodified lines
58405851 t.Fatalf("unexpected OpenAI path: %s", r.URL.Path)
58415852 }
58425853 if got := r.Header.Get("Authorization"); got != "Bearer test-openai-key" {
5843− t.Fatalf("authorization = %q", got)
5854+ t.Fatalf("authorization mismatch: present=%t length=%d", got != "", len(got))
58445855 }
58455856 var payload struct {
58465857 Input []string `json:"input"`
@@ -6289,7 +6300,7 @@ func TestSyncCommandUsesConfiguredGitHubBaseURLAndHydratesComments(t *testing.T) · 442 unmodified lines
62896300
62906301 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
62916302 if got := r.Header.Get("Authorization"); got != "Bearer test-gh-token" {
6292− t.Fatalf("authorization = %q", got)
6303+ t.Fatalf("authorization mismatch: present=%t length=%d", got != "", len(got))
62936304 }
62946305 switch r.URL.Path {
62956306 case "/repos/openclaw/openclaw":
@@ -6459,7 +6470,7 @@ func TestFillPRDetailsHydratesMissingPullRequestDetails(t *testing.T) { · 163 unmodified lines
64596470
64606471 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
64616472 if got := r.Header.Get("Authorization"); got != "Bearer test-gh-token" {
6462− t.Fatalf("authorization = %q", got)
6473+ t.Fatalf("authorization mismatch: present=%t length=%d", got != "", len(got))
64636474 }
64646475 w.Header().Set("X-RateLimit-Limit", "5000")
64656476 w.Header().Set("X-RateLimit-Remaining", "4990")
@@ -6710,7 +6721,7 @@ func TestFillPRDetailsReserveRateLimitStopsBeforeCrossingDuringBatch(t *testing. · 244 unmodified lines
67106721 var coreCalls atomic.Int32
67116722 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
67126723 if got := r.Header.Get("Authorization"); got != "Bearer test-gh-token" {
6713− t.Fatalf("authorization = %q", got)
6724+ t.Fatalf("authorization mismatch: present=%t length=%d", got != "", len(got))
67146725 }
67156726 if r.URL.Path == "/rate_limit" {
67166727 remaining := 12 - int(rateStatusCalls.Add(1))
internal/cli/cloud_commands_test.go+3−3
@@ -162,7 +162,7 @@ func TestSendSnapshotIngestDatasetStreamsBoundedBatches(t *testing.T) { · 161 unmodified lines
162162 t.Fatalf("stream dataset: %v", err)
163163 }
164164 if progress.RowsAccepted != 501 || progress.MutationToken != "mutation-3" {
165− t.Fatalf("progress = %#v", progress)
165+ t.Fatalf("progress mismatch: rows_accepted=%d mutation_token_present=%t mutation_token_length=%d", progress.RowsAccepted, progress.MutationToken != "", len(progress.MutationToken))
166166 }
167167 if len(requests) != 3 {
168168 t.Fatalf("requests = %d, want 3", len(requests))
@@ -253,7 +253,7 @@ func TestSendSnapshotIngestDatasetFlushesBeforeEncodedByteLimit(t *testing.T) { · 84 unmodified lines
253253 t.Fatalf("stream byte-bounded dataset: %v", err)
254254 }
255255 if progress.RowsAccepted != 3 || progress.MutationToken != "mutation-3" {
256− t.Fatalf("progress = %#v", progress)
256+ t.Fatalf("progress mismatch: rows_accepted=%d mutation_token_present=%t mutation_token_length=%d", progress.RowsAccepted, progress.MutationToken != "", len(progress.MutationToken))
257257 }
258258 if len(requests) != 3 {
259259 t.Fatalf("requests = %d, want one per large row", len(requests))
@@ -331,7 +331,7 @@ func TestSendSnapshotIngestRowsFlushesBeforeEncodedByteLimit(t *testing.T) { · 71 unmodified lines
331331 t.Fatalf("send byte-bounded rows: %v", err)
332332 }
333333 if progress.RowsAccepted != 3 || progress.MutationToken != "mutation-3" {
334− t.Fatalf("progress = %#v", progress)
334+ t.Fatalf("progress mismatch: rows_accepted=%d mutation_token_present=%t mutation_token_length=%d", progress.RowsAccepted, progress.MutationToken != "", len(progress.MutationToken))
335335 }
336336 if len(requests) != 3 {
337337 t.Fatalf("requests = %d, want one per large row", len(requests))
internal/cli/github_token.go+5−1
@@ -16,7 +16,11 @@ func (a *App) resolveGitHubToken(ctx context.Context, cfg config.Config) config. · 15 unmodified lines
1616 if token.Value != "" {
1717 return token
1818 }
19− if value, err := a.githubAuthToken(ctx); err == nil && value != "" {
19+ lookup := a.githubAuthToken
20+ if a.githubAuthTokenLookup != nil {
21+ lookup = a.githubAuthTokenLookup
22+ }
23+ if value, err := lookup(ctx); err == nil && value != "" {
2024 return config.TokenResolution{Value: value, Source: "gh auth token"}
2125 }
2226 return token
internal/cli/github_token_test.go+12−16
@@ -13,35 +13,31 @@ import ( · 12 unmodified lines
1313 )
1414
1515 func TestResolveGitHubTokenFallsBackToGHAuthToken(t *testing.T) {
16− dir := t.TempDir()
17− ghPath := filepath.Join(dir, "gh")
18− if err := os.WriteFile(ghPath, []byte("#!/bin/sh\nif [ \"$1\" = auth ] && [ \"$2\" = token ]; then echo gh-fallback-token; exit 0; fi\nexit 1\n"), 0o755); err != nil {
19− t.Fatalf("write fake gh: %v", err)
20− }
2116 t.Setenv("GITHUB_TOKEN", "")
22− t.Setenv("GITCRAWL_GH_PATH", ghPath)
2317
24− token := New().resolveGitHubToken(context.Background(), config.Default())
18+ app := New()
19+ app.githubAuthTokenLookup = func(context.Context) (string, error) {
20+ return "gh-fallback-token", nil
21+ }
22+ token := app.resolveGitHubToken(context.Background(), config.Default())
2523 if token.Value != "gh-fallback-token" || token.Source != "gh auth token" {
26− t.Fatalf("token = %#v", token)
24+ t.Fatalf("token mismatch: source=%q value_present=%t value_length=%d", token.Source, token.Value != "", len(token.Value))
2725 }
2826 }
2927
3028 func TestDoctorReportsGHAuthTokenFallback(t *testing.T) {
3129 dir := t.TempDir()
32− ghPath := filepath.Join(dir, "gh")
33− if err := os.WriteFile(ghPath, []byte("#!/bin/sh\nif [ \"$1\" = auth ] && [ \"$2\" = token ]; then echo gh-fallback-token; exit 0; fi\nexit 1\n"), 0o755); err != nil {
34− t.Fatalf("write fake gh: %v", err)
35− }
3630 configPath := filepath.Join(dir, "config.toml")
3731 dbPath := filepath.Join(dir, "gitcrawl.db")
3832 if err := os.WriteFile(configPath, []byte("version = 1\ndb_path = "+strconv.Quote(dbPath)+"\n[github]\ntoken_env = 'GITHUB_TOKEN'\n"), 0o600); err != nil {
3933 t.Fatalf("write config: %v", err)
4034 }
4135 t.Setenv("GITHUB_TOKEN", "")
42− t.Setenv("GITCRAWL_GH_PATH", ghPath)
4336
4437 doctor := New()
38+ doctor.githubAuthTokenLookup = func(context.Context) (string, error) {
39+ return "gh-fallback-token", nil
40+ }
4541 var stdout bytes.Buffer
4642 doctor.Stdout = &stdout
4743 if err := doctor.Run(context.Background(), []string{"--config", configPath, "doctor", "--json"}); err != nil {
@@ -49,12 +45,12 @@ func TestDoctorReportsGHAuthTokenFallback(t *testing.T) { · 1 unmodified line
4945 }
5046 var payload map[string]any
5147 if err := json.Unmarshal(stdout.Bytes(), &payload); err != nil {
52− t.Fatalf("parse doctor json: %v\n%s", err, stdout.String())
48+ t.Fatalf("parse doctor json: %v (output_bytes=%d)", err, stdout.Len())
5349 }
5450 if got := payload["github_token_present"]; got != true {
55− t.Fatalf("github_token_present = %#v, payload=%s", got, stdout.String())
51+ t.Fatalf("github_token_present = %#v", got)
5652 }
5753 if got := payload["github_token_source"]; got != "gh auth token" {
58− t.Fatalf("github_token_source = %#v, payload=%s", got, stdout.String())
54+ t.Fatalf("github_token_source = %#v", got)
5955 }
6056 }
internal/cli/remote_commands_test.go+20−11
@@ -81,7 +81,13 @@ func TestPollRemoteLoginStates(t *testing.T) { · 80 unmodified lines
8181 t.Fatalf("poll login: %v", err)
8282 }
8383 if result.Token != "session-token" || polls != 2 {
84− t.Fatalf("result=%#v polls=%d", result, polls)
84+ t.Fatalf(
85+ "poll result mismatch: status=%q token_present=%t token_length=%d polls=%d",
86+ result.Status,
87+ result.Token != "",
88+ len(result.Token),
89+ polls,
90+ )
8591 }
8692 })
8793
@@ -154,10 +160,10 @@ func TestSendIngestRowsBatchesAndFinalizes(t *testing.T) { · 66 unmodified lines
154160 t.Fatalf("requests len = %d", len(requests))
155161 }
156162 if requests[0].Cursor != "" || requests[0].Final || len(requests[0].Rows) != gitcrawlCloudBatchSize {
157− t.Fatalf("first request = %#v", requests[0])
163+ t.Fatalf("first request mismatch: cursor=%q final=%t rows=%d", requests[0].Cursor, requests[0].Final, len(requests[0].Rows))
158164 }
159165 if requests[1].Cursor != "250" || !requests[1].Final || len(requests[1].Rows) != 1 {
160− t.Fatalf("second request = %#v", requests[1])
166+ t.Fatalf("second request mismatch: cursor=%q final=%t rows=%d", requests[1].Cursor, requests[1].Final, len(requests[1].Rows))
161167 }
162168 }
163169
@@ -207,16 +213,16 @@ func TestSendSnapshotIngestRowsRotatesMutationTokens(t *testing.T) { · 43 unmodified lines
207213 t.Fatalf("send snapshot ingest: %v", err)
208214 }
209215 if progress.RowsAccepted != int64(len(rows)) || progress.MutationToken != "generation-2" {
210− t.Fatalf("progress = %#v", progress)
216+ t.Fatalf("progress mismatch: rows_accepted=%d mutation_token_present=%t mutation_token_length=%d", progress.RowsAccepted, progress.MutationToken != "", len(progress.MutationToken))
211217 }
212218 if len(requests) != 2 {
213− t.Fatalf("requests = %#v", requests)
219+ t.Fatalf("requests length = %d, want 2", len(requests))
214220 }
215221 if requests[0].Cursor != "" || requests[0].MutationToken != "previous-dataset" {
216− t.Fatalf("first request = %#v", requests[0])
222+ t.Fatalf("first request mismatch: cursor=%q mutation_token_present=%t mutation_token_length=%d", requests[0].Cursor, requests[0].MutationToken != "", len(requests[0].MutationToken))
217223 }
218224 if requests[1].Cursor != "250" || requests[1].MutationToken != "generation-1" || !requests[1].Final {
219− t.Fatalf("second request = %#v", requests[1])
225+ t.Fatalf("second request mismatch: cursor=%q final=%t mutation_token_present=%t mutation_token_length=%d", requests[1].Cursor, requests[1].Final, requests[1].MutationToken != "", len(requests[1].MutationToken))
220226 }
221227 }
222228
@@ -287,17 +293,20 @@ func TestSendIngestRowsDrainsRemoteResetBeforeRetry(t *testing.T) { · 64 unmodified lines
287293 t.Fatalf("send ingest: %v", err)
288294 }
289295 if progress.RowsAccepted != 1 || progress.MutationToken != "generation-current" {
290− t.Fatalf("progress = %#v", progress)
296+ t.Fatalf("progress mismatch: rows_accepted=%d mutation_token_present=%t mutation_token_length=%d", progress.RowsAccepted, progress.MutationToken != "", len(progress.MutationToken))
291297 }
292298 if resetCalls != 2 {
293299 t.Fatalf("resetCalls = %d", resetCalls)
294300 }
295− if len(requests) != 1 || requests[0].Cursor != "" || !requests[0].Final {
296− t.Fatalf("data requests = %#v", requests)
301+ if len(requests) != 1 {
302+ t.Fatalf("data requests length = %d, want 1", len(requests))
303+ }
304+ if requests[0].Cursor != "" || !requests[0].Final {
305+ t.Fatalf("data request mismatch: cursor=%q final=%t", requests[0].Cursor, requests[0].Final)
297306 }
298307 for index, request := range drainRequests {
299308 if request.MutationToken != "generation-current" {
300− t.Fatalf("drain request %d mutation token = %q", index, request.MutationToken)
309+ t.Fatalf("drain request %d mutation token mismatch: present=%t length=%d", index, request.MutationToken != "", len(request.MutationToken))
301310 }
302311 }
303312 }
internal/config/config_test.go+12−12
@@ -319,10 +319,10 @@ func TestResolveTokens(t *testing.T) { · 318 unmodified lines
319319
320320 cfg := Default()
321321 if got := ResolveGitHubToken(cfg); got.Value != "ghp_test" || got.Source != "GITHUB_TOKEN" {
322− t.Fatalf("github token resolution mismatch: %#v", got)
322+ t.Fatalf("github token resolution mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
323323 }
324324 if got := ResolveOpenAIKey(cfg); got.Value != "sk_test" || got.Source != "OPENAI_API_KEY" {
325− t.Fatalf("openai key resolution mismatch: %#v", got)
325+ t.Fatalf("openai key resolution mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
326326 }
327327
328328 t.Setenv("GITHUB_TOKEN", "")
@@ -332,19 +332,19 @@ func TestResolveTokens(t *testing.T) { · 3 unmodified lines
332332 t.Setenv("CUSTOM_GITHUB_TOKEN", "custom-gh")
333333 t.Setenv("CUSTOM_OPENAI_KEY", "custom-openai")
334334 if got := ResolveGitHubToken(cfg); got.Value != "custom-gh" || got.Source != "CUSTOM_GITHUB_TOKEN" {
335− t.Fatalf("custom github token mismatch: %#v", got)
335+ t.Fatalf("custom github token mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
336336 }
337337 if got := ResolveOpenAIKey(cfg); got.Value != "custom-openai" || got.Source != "CUSTOM_OPENAI_KEY" {
338− t.Fatalf("custom openai key mismatch: %#v", got)
338+ t.Fatalf("custom openai key mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
339339 }
340340
341341 t.Setenv("CUSTOM_GITHUB_TOKEN", "")
342342 t.Setenv("CUSTOM_OPENAI_KEY", "")
343343 if got := ResolveGitHubToken(cfg); got.Value != "" || got.Source != "" {
344− t.Fatalf("empty github token mismatch: %#v", got)
344+ t.Fatalf("empty github token mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
345345 }
346346 if got := ResolveOpenAIKey(cfg); got.Value != "" || got.Source != "" {
347− t.Fatalf("empty openai key mismatch: %#v", got)
347+ t.Fatalf("empty openai key mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
348348 }
349349 }
350350
@@ -358,15 +358,15 @@ func TestResolveTokensFromConfigEnv(t *testing.T) { · 7 unmodified lines
358358 "OPENAI_API_KEY": "config-openai",
359359 }
360360 if got := ResolveGitHubToken(cfg); got.Value != "config-gh" || got.Source != "config.toml [env].GITHUB_TOKEN" {
361− t.Fatalf("github token config env mismatch: %#v", got)
361+ t.Fatalf("github token config env mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
362362 }
363363 if got := ResolveOpenAIKey(cfg); got.Value != "config-openai" || got.Source != "config.toml [env].OPENAI_API_KEY" {
364− t.Fatalf("openai key config env mismatch: %#v", got)
364+ t.Fatalf("openai key config env mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
365365 }
366366
367367 t.Setenv("GITHUB_TOKEN", "process-gh")
368368 if got := ResolveGitHubToken(cfg); got.Value != "process-gh" || got.Source != "GITHUB_TOKEN" {
369− t.Fatalf("process env should win: %#v", got)
369+ t.Fatalf("process env should win: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
370370 }
371371 }
372372
@@ -384,15 +384,15 @@ func TestResolveTokensFromCustomConfigEnv(t *testing.T) { · 11 unmodified lines
384384 "OPENAI_API_KEY": "ignored-default-openai",
385385 }
386386 if got := ResolveGitHubToken(cfg); got.Value != "config-custom-gh" || got.Source != "config.toml [env].CUSTOM_GITHUB_TOKEN" {
387− t.Fatalf("custom github token config env mismatch: %#v", got)
387+ t.Fatalf("custom github token config env mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
388388 }
389389 if got := ResolveOpenAIKey(cfg); got.Value != "config-custom-openai" || got.Source != "config.toml [env].CUSTOM_OPENAI_KEY" {
390− t.Fatalf("custom openai key config env mismatch: %#v", got)
390+ t.Fatalf("custom openai key config env mismatch: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
391391 }
392392
393393 cfg.Env["CUSTOM_GITHUB_TOKEN"] = " "
394394 if got := ResolveGitHubToken(cfg); got.Value != "" || got.Source != "" {
395− t.Fatalf("empty config env should be ignored: %#v", got)
395+ t.Fatalf("empty config env should be ignored: source=%q value_present=%t value_length=%d", got.Source, got.Value != "", len(got.Value))
396396 }
397397 }
398398
internal/config/remote_token_test.go+2−2
@@ -40,7 +40,7 @@ func TestRemoteTokenResolutionWithKeyring(t *testing.T) { · 39 unmodified lines
4040 t.Fatalf("resolve env token: %v", err)
4141 }
4242 if resolved.Value != "env-session" || resolved.Source != "GITCRAWL_TEST_REMOTE_TOKEN" {
43− t.Fatalf("env token = %#v", resolved)
43+ t.Fatalf("env token mismatch: source=%q value_present=%t value_length=%d", resolved.Source, resolved.Value != "", len(resolved.Value))
4444 }
4545
4646 t.Setenv("GITCRAWL_TEST_REMOTE_TOKEN", "")
@@ -57,7 +57,7 @@ func TestRemoteTokenResolutionWithKeyring(t *testing.T) { · 10 unmodified lines
5757 t.Fatalf("resolve keyring token: %v", err)
5858 }
5959 if resolved.Value != "keyring-session" || resolved.Source != "keyring" {
60− t.Fatalf("keyring token = %#v", resolved)
60+ t.Fatalf("keyring token mismatch: source=%q value_present=%t value_length=%d", resolved.Source, resolved.Value != "", len(resolved.Value))
6161 }
6262
6363 cfg.Remote.Auth.TokenSource = "none"
internal/github/client_test.go+2−2
@@ -27,8 +27,8 @@ func writeRateLimits(t *testing.T, w http.ResponseWriter, resetAt time.Time, cor · 26 unmodified lines
2727
2828 func TestListRepositoryIssuesPaginatesAndLimits(t *testing.T) {
2929 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
30− if r.Header.Get("Authorization") != "Bearer token" {
31− t.Fatalf("missing auth header: %q", r.Header.Get("Authorization"))
30+ if got := r.Header.Get("Authorization"); got != "Bearer token" {
31+ t.Fatalf("auth header mismatch: present=%t length=%d", got != "", len(got))
3232 }
3333 switch r.URL.Query().Get("page") {
3434 case "":
internal/openai/summaries_test.go+1−1
@@ -18,7 +18,7 @@ func TestSummarizeUsesResponsesOutputText(t *testing.T) { · 17 unmodified lines
1818 t.Fatalf("path = %q", r.URL.Path)
1919 }
2020 if got := r.Header.Get("Authorization"); got != "Bearer test-key" {
21− t.Fatalf("authorization = %q", got)
21+ t.Fatalf("authorization mismatch: present=%t length=%d", got != "", len(got))
2222 }
2323 var request summaryRequest
2424 if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
internal/store/sync_failures_test.go+1−1
@@ -402,6 +402,6 @@ func assertPortableFileDoesNotContain(t *testing.T, path, value string) { · 401 unmodified lines
402402 t.Fatalf("read portable database bytes: %v", err)
403403 }
404404 if bytes.Contains(data, []byte(value)) {
405− t.Fatalf("portable database retains scrubbed value %q", value)
405+ t.Fatal("portable database retains a scrubbed credential value")
406406 }
407407 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t