Welcome to mirror list, hosted at ThFree Co, Russian Federation.

alias_test.go « target - github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec686af5402586a713eec0fdbca1fa998ee76a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package target

import (
	"path/filepath"
	"testing"
)

func TestHTMLRedirectAlias(t *testing.T) {
	var o Translator
	o = new(HTMLRedirectAlias)

	tests := []struct {
		value    string
		expected string
	}{
		{"", ""},
		{"s", filepath.FromSlash("s/index.html")},
		{"/", filepath.FromSlash("/index.html")},
		{"alias 1", filepath.FromSlash("alias-1/index.html")},
		{"alias 2/", filepath.FromSlash("alias-2/index.html")},
		{"alias 3.html", "alias-3.html"},
		{"alias4.html", "alias4.html"},
		{"/alias 5.html", filepath.FromSlash("/alias-5.html")},
		{"/трям.html", filepath.FromSlash("/трям.html")},
	}

	for _, test := range tests {
		path, err := o.Translate(test.value)
		if err != nil {
			t.Fatalf("Translate returned an error: %s", err)
		}

		if path != test.expected {
			t.Errorf("Expected: %s, got: %s", test.expected, path)
		}
	}
}