diff options
Diffstat (limited to 'hugolib/language_content_dir_test.go')
-rw-r--r-- | hugolib/language_content_dir_test.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/hugolib/language_content_dir_test.go b/hugolib/language_content_dir_test.go index 3c3642bf3..577fdfaeb 100644 --- a/hugolib/language_content_dir_test.go +++ b/hugolib/language_content_dir_test.go @@ -81,6 +81,9 @@ weight: %d Content. +SVP3-REF: {{< ref path="/sect/page3.md" lang="sv" >}} +SVP3-RELREF: {{< relref path="/sect/page3.md" lang="sv" >}} + ` pageBundleTemplate := ` @@ -211,24 +214,32 @@ Content. assert.NoError(err) nnP2, err := nnSite.getPageNew(nil, "/sect/page2.md") assert.NoError(err) - nnP2_2, err := svSite.getPageNew(nil, "/nn/sect/page2.md") - assert.NoError(err) - enP2_2, err := nnSite.getPageNew(nil, "/en/sect/page2.md") - assert.NoError(err) - svP2_2, err := enSite.getPageNew(nil, "/sv/sect/page2.md") - assert.NoError(err) enP2, err := enSite.getPageNew(nil, "/sect/page2.md") assert.NoError(err) - assert.NotNil(enP2) - assert.NotNil(svP2) - assert.NotNil(nnP2) + assert.Equal("en", enP2.Lang()) assert.Equal("sv", svP2.Lang()) assert.Equal("nn", nnP2.Lang()) - assert.Equal("en", enP2.Lang()) - assert.Equal(nnP2, nnP2_2) - assert.Equal(enP2, enP2_2) - assert.Equal(svP2, svP2_2) + + content, _ := nnP2.Content() + assert.Contains(content, "SVP3-REF: https://example.org/sv/sect/p-sv-3/") + assert.Contains(content, "SVP3-RELREF: /sv/sect/p-sv-3/") + + // Test RelRef with and without language indicator. + nn3RefArgs := map[string]interface{}{ + "path": "/sect/page3.md", + "lang": "nn", + } + nnP3RelRef, err := svP2.RelRef( + nn3RefArgs, + ) + assert.NoError(err) + assert.Equal("/nn/sect/p-nn-3/", nnP3RelRef) + nnP3Ref, err := svP2.Ref( + nn3RefArgs, + ) + assert.NoError(err) + assert.Equal("https://example.org/nn/sect/p-nn-3/", nnP3Ref) for i, p := range enSite.RegularPages { j := i + 1 |