diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-07-25 22:22:09 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:15 +0300 |
commit | c4e7c37055a029a26d87ebeb21614efb3f0b0040 (patch) | |
tree | 55c05751d0734ace44783bc0b196873fd889d590 /hugolib/site_test.go | |
parent | 06d12ab895a83fc8a9f94b23e533b25511bbb6d1 (diff) |
Add Translations and AllTranslations methods to Page
Will revisit Node later.
Diffstat (limited to 'hugolib/site_test.go')
-rw-r--r-- | hugolib/site_test.go | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 9f29bf376..78004aac4 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -1399,12 +1399,6 @@ NOTE: should use the "permalinks" configuration with :filename hugofs.InitMemFs() - s := &Site{ - Source: &source.InMemorySource{ByteSource: sources}, - Multilingual: &Multilingual{ - enabled: true, - }, - } // Multilingual settings viper.Set("Multilingual", true) en := NewLanguage("en") @@ -1412,6 +1406,14 @@ NOTE: should use the "permalinks" configuration with :filename viper.Set("DefaultContentLanguage", "fr") viper.Set("paginate", "2") + languages := NewLanguages(en, NewLanguage("fr")) + s := &Site{ + Source: &source.InMemorySource{ByteSource: sources}, + Multilingual: &Multilingual{ + Languages: languages, + }, + } + s.prepTemplates() s.initializeSiteInfo() @@ -1425,7 +1427,7 @@ NOTE: should use the "permalinks" configuration with :filename permalink, err := doc1en.Permalink() assert.NoError(t, err, "permalink call failed") assert.Equal(t, "http://example.com/blog/en/sect/doc1-slug", permalink, "invalid doc1.en permalink") - assert.Len(t, doc1en.Translations, 1, "doc1-en should have one translation, excluding itself") + assert.Len(t, doc1en.Translations(), 1, "doc1-en should have one translation, excluding itself") doc2 := s.Pages[1] permalink, err = doc2.Permalink() @@ -1440,19 +1442,20 @@ NOTE: should use the "permalinks" configuration with :filename assert.Equal(t, doc2.Next, doc3, "doc3 should follow doc2, in .Next") - doc1fr := doc1en.Translations["fr"] + doc1fr := doc1en.Translations()[0] permalink, err = doc1fr.Permalink() assert.NoError(t, err, "permalink call failed") assert.Equal(t, "http://example.com/blog/fr/sect/doc1", permalink, "invalid doc1fr permalink") - assert.Equal(t, doc1en.Translations["fr"], doc1fr, "doc1-en should have doc1-fr as translation") - assert.Equal(t, doc1fr.Translations["en"], doc1en, "doc1-fr should have doc1-en as translation") + assert.Equal(t, doc1en.Translations()[0], doc1fr, "doc1-en should have doc1-fr as translation") + assert.Equal(t, doc1fr.Translations()[0], doc1en, "doc1-fr should have doc1-en as translation") + assert.Equal(t, "fr", doc1fr.Language().Lang) doc4 := s.AllPages[4] permalink, err = doc4.Permalink() assert.NoError(t, err, "permalink call failed") assert.Equal(t, "http://example.com/blog/fr/sect/doc4", permalink, "invalid doc4 permalink") - assert.Len(t, doc4.Translations, 0, "found translations for doc4") + assert.Len(t, doc4.Translations(), 0, "found translations for doc4") doc5 := s.AllPages[5] permalink, err = doc5.Permalink() |