mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
@@ -1,6 +1,7 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -26,6 +27,28 @@ func TestURLize(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAbsURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
baseURL string
|
||||
expected string
|
||||
}{
|
||||
{"/test/foo", "http://base/", "http://base/test/foo"},
|
||||
{"", "http://base/ace/", "http://base/ace/"},
|
||||
{"/test/2/foo/", "http://base", "http://base/test/2/foo/"},
|
||||
{"http://abs", "http://base/", "http://abs"},
|
||||
{"//schemaless", "http://base/", "//schemaless"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
viper.Set("BaseURL", test.baseURL)
|
||||
output := AbsURL(test.input)
|
||||
if output != test.expected {
|
||||
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitizeURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
|
Reference in New Issue
Block a user