Check errors by identity, not by message text, in tests (closes #49)
check / check (push) Failing after 1s

Tests that asserted a failure by a fragment of its message now use
errors.Is: a refactor returning the wrong error, or wrapping with %v
instead of %w, now fails them. New tests return each exported error of
internal/vault and pkg/bip85 that no test returned, and check wrapped
causes (os.ErrNotExist, ErrMnemonicMismatch through GetSecret,
ErrInvalidPathComponent through DeriveBIP85Entropy). The 999-versions
test moves into package secret to name its unexported error. Checks of
errors no test can name keep their text; they are listed on the issue.

Model: opus-5-5
This commit was merged in pull request #112.
This commit is contained in:
2026-10-04 23:25:06 +02:00
parent 2adc588ace
commit 176095e3d1
19 changed files with 401 additions and 256 deletions
+2 -4
View File
@@ -143,8 +143,7 @@ func TestVaultAddSecretMultipleVersions(t *testing.T) {
defer failBuffer.Destroy()
err := vault.AddSecret(testSecretPath, failBuffer, false)
require.Error(t, err)
assert.Contains(t, err.Error(), "already exists")
require.ErrorIs(t, err, ErrSecretExists)
// Add with force - should create new version
addTestSecretToVault(t, vault, testSecretPath, []byte("version-2"), true)
@@ -309,8 +308,7 @@ func TestVaultGetNonExistentVersion(t *testing.T) {
// Try to get non-existent version
_, err := vault.GetSecretVersion(testSecretPath, "20991231.999")
require.Error(t, err)
assert.Contains(t, err.Error(), "not found")
require.ErrorIs(t, err, ErrVersionNotFound)
}
func TestUpdateVersionMetadata(t *testing.T) {