URI: 
       Increase refLinker test coverage - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 8278384b9680cfdcecef9c668638ad483012857f
   DIR parent 65e610e1617647a7dc6bb9f7794cfad068cb3615
  HTML Author: Vas Sudanagunta <vas@commonkarma.org>
       Date:   Thu, 19 Jul 2018 19:04:45 -0400
       
       Increase refLinker test coverage
       
       Diffstat:
         M hugolib/site_test.go                |      49 +++++++++++++++++++++++++++++--
       
       1 file changed, 46 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/hugolib/site_test.go b/hugolib/site_test.go
       @@ -874,6 +874,8 @@ func TestWeightedTaxonomies(t *testing.T) {
        func setupLinkingMockSite(t *testing.T) *Site {
                sources := [][2]string{
                        {filepath.FromSlash("level2/unique.md"), ""},
       +                {filepath.FromSlash("_index.md"), ""},
       +                {filepath.FromSlash("common.md"), ""},
                        {filepath.FromSlash("rootfile.md"), ""},
                        {filepath.FromSlash("root-image.png"), ""},
        
       @@ -884,10 +886,13 @@ func setupLinkingMockSite(t *testing.T) *Site {
                        {filepath.FromSlash("level2/common.png"), ""},
        
                        {filepath.FromSlash("level2/level3/start.md"), ""},
       +                {filepath.FromSlash("level2/level3/_index.md"), ""},
                        {filepath.FromSlash("level2/level3/3-root.md"), ""},
                        {filepath.FromSlash("level2/level3/common.md"), ""},
                        {filepath.FromSlash("level2/level3/3-image.png"), ""},
                        {filepath.FromSlash("level2/level3/common.png"), ""},
       +
       +                {filepath.FromSlash("level2/level3/embedded.dot.md"), ""},
                }
        
                cfg, fs := newTestCfg()
       @@ -921,14 +926,52 @@ func TestRefLinking(t *testing.T) {
                        relative     bool
                        expected     string
                }{
       +                // different refs resolving to the same unique filename:
       +                {"/level2/unique.md", "", true, "/level2/unique/"},
       +                {"../unique.md", "", true, "/level2/unique/"},
                        {"unique.md", "", true, "/level2/unique/"},
       +
                        {"level2/common.md", "", true, "/level2/common/"},
                        {"3-root.md", "", true, "/level2/level3/3-root/"},
       +                {"../..", "", true, "/"},
       +
       +                // different refs resolving to the same ambiguous top-level filename:
       +                {"../../common.md", "", true, "/common/"},
       +                {"/common.md", "", true, "/common/"},
       +
       +                // different refs resolving to the same ambiguous level-2 filename:
       +                {"/level2/common.md", "", true, "/level2/common/"},
       +                {"../common.md", "", true, "/level2/common/"},
       +                {"common.md", "", true, "/level2/level3/common/"},
       +
       +                // different refs resolving to the same section:
       +                {"/level2", "", true, "/level2/"},
       +                {"..", "", true, "/level2/"},
       +                {"../", "", true, "/level2/"},
       +
       +                // different refs resolving to the same subsection:
       +                {"/level2/level3", "", true, "/level2/level3/"},
       +                {"/level2/level3/_index.md", "", true, "/level2/level3/"},
       +                {".", "", true, "/level2/level3/"},
       +                {"./", "", true, "/level2/level3/"},
       +
       +                // try to confuse parsing
       +                {"embedded.dot.md", "", true, "/level2/level3/embedded.dot/"},
       +
       +                //test empty link, as well as fragment only link
       +                {"", "", true, ""},
                } {
       -                if out, err := site.refLink(test.link, currentPage, test.relative, test.outputFormat); err != nil || out != test.expected {
       -                        t.Errorf("[%d] Expected %s to resolve to (%s), got (%s) - error: %s", i, test.link, test.expected, out, err)
       -                }
       +                checkLinkCase(site, test.link, currentPage, test.relative, test.outputFormat, test.expected, t, i)
       +
       +                //make sure fragment links are also handled
       +                checkLinkCase(site, test.link+"#intro", currentPage, test.relative, test.outputFormat, test.expected+"#intro", t, i)
                }
        
                // TODO: and then the failure cases.
        }
       +
       +func checkLinkCase(site *Site, link string, currentPage *Page, relative bool, outputFormat string, expected string, t *testing.T, i int) {
       +        if out, err := site.refLink(link, currentPage, relative, outputFormat); err != nil || out != expected {
       +                t.Errorf("[%d] Expected %q from %q to resolve to %q, got %q - error: %s", i, link, currentPage.absoluteSourceRef(), expected, out, err)
       +        }
       +}