(t *testing.T)
| 422 | } |
| 423 | |
| 424 | func 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 | |
| 461 | func TestOpenKeyring_NoDBus_ForcesFileBackend(t *testing.T) { |
| 462 | if runtime.GOOS != "linux" { |
nothing calls this directly
no test coverage detected