MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestOpenKeyringWithTimeout_Timeout

Function TestOpenKeyringWithTimeout_Timeout

internal/secrets/store_test.go:424–459  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

422}
423
424func TestOpenKeyringWithTimeout_Timeout(t *testing.T) {
425 home := t.TempDir()
426 t.Setenv("HOME", home)
427 t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, "xdg-config"))
428 t.Setenv("GOG_KEYRING_BACKEND", "file")
429 t.Setenv("GOG_KEYRING_PASSWORD", "testpass")
430
431 keyringDir, err := testSystemLayout(t, config.PathKindConfig, config.PathKindData).EnsureKeyringDir()
432 if err != nil {
433 t.Fatalf("EnsureKeyringDir: %v", err)
434 }
435
436 cfg := keyringConfig(keyringDir)
437
438 blockCh := make(chan struct{})
439 open := func(_ keyring.Config) (keyring.Keyring, error) {
440 <-blockCh
441 return nil, errKeyringOpenBlocked
442 }
443
444 _, err = openKeyringWithTimeoutFunc(cfg, 10*time.Millisecond, keyringTimeoutHint(runtime.GOOS), open)
445
446 close(blockCh)
447
448 if err == nil {
449 t.Fatalf("expected timeout error")
450 }
451
452 if !errors.Is(err, errKeyringTimeout) {
453 t.Fatalf("expected keyring timeout error, got: %v", err)
454 }
455
456 if !strings.Contains(err.Error(), "GOG_KEYRING_BACKEND=file") {
457 t.Fatalf("expected timeout error with GOG_KEYRING_BACKEND guidance, got: %v", err)
458 }
459}
460
461func TestOpenKeyring_NoDBus_ForcesFileBackend(t *testing.T) {
462 if runtime.GOOS != "linux" {

Callers

nothing calls this directly

Calls 6

keyringConfigFunction · 0.85
keyringTimeoutHintFunction · 0.85
EnsureKeyringDirMethod · 0.80
testSystemLayoutFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected