Comprehensive quality pass targeting 1.0 release: - Code review and refactoring - Fix open bugs (#14, #16, #23) - Expand test coverage - Lint clean - README update with build instructions (#9) - Documentation improvements Branched from `next` (active dev branch). Reviewed-on: #32 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package mfer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBaseURLJoinPath(t *testing.T) {
|
|
tests := []struct {
|
|
base BaseURL
|
|
path RelFilePath
|
|
expected string
|
|
}{
|
|
{"https://example.com/dir/", "file.txt", "https://example.com/dir/file.txt"},
|
|
{"https://example.com/dir", "file.txt", "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) {
|
|
result, err := tt.base.JoinPath(tt.path)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, tt.expected, string(result))
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestBaseURLString(t *testing.T) {
|
|
b := BaseURL("https://example.com/")
|
|
assert.Equal(t, "https://example.com/", b.String())
|
|
}
|
|
|
|
func TestFileURLString(t *testing.T) {
|
|
f := FileURL("https://example.com/file.txt")
|
|
assert.Equal(t, "https://example.com/file.txt", f.String())
|
|
}
|
|
|
|
func TestManifestURLString(t *testing.T) {
|
|
m := ManifestURL("https://example.com/index.mf")
|
|
assert.Equal(t, "https://example.com/index.mf", m.String())
|
|
}
|