summaryrefslogtreecommitdiffstats
path: root/target/alias_test.go
blob: b25fe84a2b07d50bb02a2c09cf51c92d1839b6ce (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
package target

import (
	"testing"
)

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

	tests := []struct {
		value    string
		expected string
	}{
		{"", ""},
		{"alias 1", "alias-1"},
		{"alias 2/", "alias-2/index.html"},
		{"alias 3.html", "alias-3.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)
		}
	}
}