diff options
author | Noah Campbell <noahcampbell@gmail.com> | 2013-09-12 21:18:13 -0700 |
---|---|---|
committer | Noah Campbell <noahcampbell@gmail.com> | 2013-09-12 21:20:00 -0700 |
commit | 2ebfb33fe01d38a1341d6fe3c922dad5e93fd769 (patch) | |
tree | 388dbe07c90f3b36bf45f92482869ec1863be468 /hugolib/site_url_test.go | |
parent | 2f10da15707e1db0fab90524a247bc8a2d3ded90 (diff) |
Move alias logic to target module
I want to move all logic to writing aliases to target so I can pave the
way for writing aliases specific to other runtimes (like .htaccess for
apache or a script for updating AWS or symlinking on a filesystem).
Diffstat (limited to 'hugolib/site_url_test.go')
-rw-r--r-- | hugolib/site_url_test.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 5f741ae83..c5146b92d 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -4,6 +4,8 @@ import ( "bytes" "io" "testing" + "html/template" + "github.com/spf13/hugo/target" ) const SLUG_DOC_1 = "---\ntitle: slug doc 1\nslug: slug-doc-1\naliases:\n - sd1/foo/\n - sd2\n - sd3/\n - sd4.php\n---\nslug doc 1 content" @@ -44,15 +46,29 @@ func (t *InMemoryTarget) Translate(label string) (dest string, err error) { return label, nil } +type InMemoryAliasTarget struct { + target.HTMLRedirectAlias + files map[string][]byte +} + +func (t *InMemoryAliasTarget) Publish(label string, permalink template.HTML) (err error) { + f, _ := t.Translate(label) + t.files[f] = []byte("--dummy text--") + return +} + var urlFakeSource = []byteSource{ {"content/blue/doc1.md", []byte(SLUG_DOC_1)}, {"content/blue/doc2.md", []byte(SLUG_DOC_2)}, } func TestPageCount(t *testing.T) { - target := new(InMemoryTarget) + files := make(map[string][]byte) + target := &InMemoryTarget{files: files} + alias := &InMemoryAliasTarget{files: files} s := &Site{ Target: target, + Alias: alias, Config: Config{UglyUrls: false}, Source: &inMemorySource{urlFakeSource}, } |