Update golangci-lint to v2.12.2 with canonical config (closes #60)
check / check (push) Has been cancelled
check / check (push) Has been cancelled
Adopts golangci-lint v2.12.2 and the canonical .golangci.yml (default: all), and fixes all resulting findings across the tree. Two intended behavior changes: absent MFFilePath.Mtime is handled explicitly in freshen, list and export rather than dereferenced (main panicked); gpg positional key IDs now follow an explicit -- end-of-options marker. All twelve reworded user-visible error messages restored to byte-identical parity with main and pinned by tests.
This commit was merged in pull request #59.
This commit is contained in:
1 parent
6d19de74e7
commit
de476708e9
40 files changed
+4012
-1798
No files matched your search
@@ -0,0 +1,85 @@
|
||||
//nolint:testpackage // white-box tests exercise unexported internals
|
||||
package mfer
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestValidatePathMessagesVerbatim pins the exact rendered text of every
|
||||
// ValidatePath rejection.
|
||||
//
|
||||
// These strings are user-visible and are assembled by wrapping static
|
||||
// sentinels mid-sentence, which makes them easy to reword by accident
|
||||
// while refactoring for errors.Is matchability. Changing one is a
|
||||
// deliberate change, not a refactoring side effect.
|
||||
func TestValidatePathMessagesVerbatim(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
path string
|
||||
want string
|
||||
is error
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
path: "",
|
||||
want: "path cannot be empty",
|
||||
is: errPathEmpty,
|
||||
},
|
||||
{
|
||||
name: "not utf8",
|
||||
path: "a\xffb",
|
||||
want: `path "a\xffb" is not valid UTF-8`,
|
||||
is: errPathNotUTF8,
|
||||
},
|
||||
{
|
||||
name: "backslash",
|
||||
path: `a\b`,
|
||||
want: `path "a\\b" contains backslash; ` +
|
||||
"use forward slashes only",
|
||||
is: errPathBackslash,
|
||||
},
|
||||
{
|
||||
name: "absolute",
|
||||
path: "/a/b",
|
||||
want: `path "/a/b" is absolute; must be relative`,
|
||||
is: errPathAbsolute,
|
||||
},
|
||||
{
|
||||
name: "empty segment",
|
||||
path: "a//b",
|
||||
want: `path "a//b" contains empty segment`,
|
||||
is: errPathEmptySegment,
|
||||
},
|
||||
{
|
||||
name: "dotdot segment",
|
||||
path: "a/../b",
|
||||
want: `path "a/../b" contains '..' segment`,
|
||||
is: errPathDotDot,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := ValidatePath(tc.path)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, tc.want, err.Error())
|
||||
require.ErrorIs(t, err, tc.is)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestSerializeInternalErrorMessagesVerbatim pins the two distinct
|
||||
// "internal error" messages, which differ between generate and
|
||||
// generateOuter and have always done so.
|
||||
func TestSerializeInternalErrorMessagesVerbatim(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
m := &manifest{}
|
||||
require.EqualError(t, m.generate(), "internal error: pbInner not set")
|
||||
require.EqualError(t, m.generateOuter(), "internal error")
|
||||
}
|
||||
Reference in new issue
Block a user