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.
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
//nolint:testpackage // white-box tests exercise unexported internals
|
|
package mfer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBaseURLJoinPath(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
base BaseURL
|
|
path RelFilePath
|
|
expected string
|
|
}{
|
|
{"https://example.com/dir/", testFileName, "https://example.com/dir/file.txt"},
|
|
{"https://example.com/dir", testFileName, "https://example.com/dir/file.txt"},
|
|
{"https://example.com/", "sub/file.txt", "https://example.com/sub/file.txt"},
|
|
{
|
|
"https://example.com/dir/",
|
|
"file with spaces.txt",
|
|
"https://example.com/dir/file%20with%20spaces.txt",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(string(tt.base)+"+"+string(tt.path), func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
result, err := tt.base.JoinPath(tt.path)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, tt.expected, string(result))
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestBaseURLString(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
b := BaseURL("https://example.com/")
|
|
assert.Equal(t, "https://example.com/", b.String())
|
|
}
|
|
|
|
func TestFileURLString(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
f := FileURL("https://example.com/file.txt")
|
|
assert.Equal(t, "https://example.com/file.txt", f.String())
|
|
}
|
|
|
|
func TestManifestURLString(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
m := ManifestURL("https://example.com/index.mf")
|
|
assert.Equal(t, "https://example.com/index.mf", m.String())
|
|
}
|