(t *testing.T)
| 282 | } |
| 283 | |
| 284 | func TestGetMasterKey_InteractivePromptError(t *testing.T) { |
| 285 | // When no env var is set and stdin is not a terminal (as in tests), |
| 286 | // term.ReadPassword will fail, triggering the error path. |
| 287 | ClearMasterKey() |
| 288 | os.Unsetenv(keyEnvVar) |
| 289 | |
| 290 | key, err := GetMasterKey() |
| 291 | // In test environments, stdin is a pipe so term.ReadPassword should fail. |
| 292 | // If for some reason it doesn't (e.g., very unusual test runner), |
| 293 | // the key should still be usable. |
| 294 | if err != nil { |
| 295 | assert.Error(t, err) |
| 296 | assert.Nil(t, key) |
| 297 | assert.Contains(t, err.Error(), "failed to read master password") |
| 298 | } |
| 299 | |
| 300 | ClearMasterKey() |
| 301 | } |
| 302 | |
| 303 | func TestGetMasterKey_AlreadyCached(t *testing.T) { |
| 304 | // Test the early return when masterKey is already cached. |
nothing calls this directly
no test coverage detected