diff options
author | Sven Dowideit <SvenDowideit@home.org.au> | 2016-03-15 16:00:36 +1000 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-04-07 20:10:38 +0200 |
commit | 1648e327c0bc7d6535667020a278b355d26a4338 (patch) | |
tree | e43d13410768f365aa299a0bf97b0cc1b7385161 /hugolib/site_test.go | |
parent | 819271cb78df6853b4c128c3899d57e3812c3078 (diff) |
Document and clean SourceRelativeLinksEval code
Diffstat (limited to 'hugolib/site_test.go')
-rw-r--r-- | hugolib/site_test.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/hugolib/site_test.go b/hugolib/site_test.go index ae3021624..dd52b6d26 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -1023,8 +1023,6 @@ func TestWeightedTaxonomies(t *testing.T) { } func findPage(site *Site, f string) *Page { - // TODO: it seems that filepath.FromSlash results in page.Source.Path() returning windows backslash - which means refLinking's string compare is totally busted. - // TODO: Not used for non-fragment linking (SVEN thinks this is a bug) currentPath := source.NewFile(filepath.FromSlash(f)) //t.Logf("looking for currentPath: %s", currentPath.Path()) @@ -1062,6 +1060,15 @@ func setupLinkingMockSite(t *testing.T) *Site { {filepath.FromSlash("level2/level3/common.png"), []byte("")}, } + viper.Set("baseurl", "http://auth/") + viper.Set("DefaultExtension", "html") + viper.Set("UglyURLs", false) + viper.Set("PluralizeListTitles", false) + viper.Set("CanonifyURLs", false) + viper.Set("blackfriday", + map[string]interface{}{ + "sourceRelativeLinksProjectFolder": "/docs"}) + site := &Site{ Source: &source.InMemorySource{ByteSource: sources}, } @@ -1072,12 +1079,6 @@ func setupLinkingMockSite(t *testing.T) *Site { t.Fatalf("Unable to create pages: %s", err) } - viper.Set("baseurl", "http://auth/bub") - viper.Set("DefaultExtension", "html") - viper.Set("UglyURLs", false) - viper.Set("PluralizeListTitles", false) - viper.Set("CanonifyURLs", false) - return site } @@ -1228,7 +1229,7 @@ func TestSourceRelativeLinksing(t *testing.T) { t.Fatalf("failed to find current page in site") } for link, url := range results { - if out, err := site.Info.githubLink(link, currentPage, true); err != nil || out != url { + if out, err := site.Info.SourceRelativeLink(link, currentPage); err != nil || out != url { t.Errorf("Expected %s to resolve to (%s), got (%s) - error: %s", link, url, out, err) } else { //t.Logf("tested ok %s maps to %s", link, out) @@ -1241,7 +1242,7 @@ func TestSourceRelativeLinksing(t *testing.T) { } -func TestGitHubFileLinking(t *testing.T) { +func TestSourceRelativeLinkFileing(t *testing.T) { viper.Reset() defer viper.Reset() site := setupLinkingMockSite(t) @@ -1278,15 +1279,11 @@ func TestGitHubFileLinking(t *testing.T) { t.Fatalf("failed to find current page in site") } for link, url := range results { - if out, err := site.Info.githubFileLink(link, currentPage, false); err != nil || out != url { + if out, err := site.Info.SourceRelativeLinkFile(link, currentPage); err != nil || out != url { t.Errorf("Expected %s to resolve to (%s), got (%s) - error: %s", link, url, out, err) } else { //t.Logf("tested ok %s maps to %s", link, out) } } } - // TODO: and then the failure cases. - // "https://docker.com": "", - // site_test.go:1094: Expected https://docker.com to resolve to (), got () - error: Not a plain filepath link (https://docker.com) - } |