From b0793b4dc6fe212af17f804f71a0f1511f126877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 4 Jan 2019 17:28:12 +0100 Subject: [PATCH] File... --- hugolib/pagination_test.go | 4 +- hugolib/site_sections_test.go | 4 +- resources/page/page.go | 8 +-- resources/page/testhelpers_test.go | 88 +++++++++++++++++++++++++++--- 4 files changed, 88 insertions(+), 16 deletions(-) diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index a4529ea1715..5d1b941a1b6 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -60,7 +60,7 @@ func TestSplitPageGroups(t *testing.T) { // first group 10 in weight require.Equal(t, 10, pg.Key) for _, p := range pg.Pages { - require.True(t, p.(*Page).fuzzyWordCount%2 == 0) // magic test + require.True(t, p.FuzzyWordCount()%2 == 0) // magic test } } } else { @@ -75,7 +75,7 @@ func TestSplitPageGroups(t *testing.T) { // last should have 5 in weight require.Equal(t, 5, pg.Key) for _, p := range pg.Pages { - require.True(t, p.(*Page).fuzzyWordCount%2 != 0) // magic test + require.True(t, p.FuzzyWordCount()%2 != 0) // magic test } } } else { diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go index b6e6023ce50..4081721b3e8 100644 --- a/hugolib/site_sections_test.go +++ b/hugolib/site_sections_test.go @@ -127,13 +127,13 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} {"elsewhere", func(p page.Page) { assert.Len(p.Pages(), 1) for _, p := range p.Pages() { - assert.Equal([]string{"elsewhere"}, p.(*Page).sections) + assert.Equal("elsewhere", p.SectionsPath()) } }}, {"post", func(p page.Page) { assert.Len(p.Pages(), 2) for _, p := range p.Pages() { - assert.Equal("post", p.(*Page).Section()) + assert.Equal("post", p.Section()) } }}, {"empty1", func(p page.Page) { diff --git a/resources/page/page.go b/resources/page/page.go index 2531749a2f5..acd725104d4 100644 --- a/resources/page/page.go +++ b/resources/page/page.go @@ -21,6 +21,7 @@ import ( "github.com/gohugoio/hugo/compare" "github.com/gohugoio/hugo/related" "github.com/gohugoio/hugo/resources/resource" + "github.com/gohugoio/hugo/source" ) // TODO(bep) page there is language and stuff going on. There will be @@ -62,9 +63,6 @@ type pageAddons interface { OutputFormats() OutputFormats - // Path is a path to this page resource with Unix-style slashes. - Path() string - // SectionsPath is path to this page's section with Unix-style slashes. SectionsPath() string @@ -84,7 +82,6 @@ type pageAddons interface { } type pageAddons2 interface { - Section() string Type() string BundleType() string Parent() Page @@ -131,6 +128,9 @@ type pageAddons6 interface { ReadingTime() int Summary() template.HTML + + // TODO(bep) page consider what to do. + source.File } // diff --git a/resources/page/testhelpers_test.go b/resources/page/testhelpers_test.go index d1175cd63b0..c1a0650411e 100644 --- a/resources/page/testhelpers_test.go +++ b/resources/page/testhelpers_test.go @@ -14,6 +14,8 @@ package page import ( + "html/template" + "os" "time" "github.com/gohugoio/hugo/langs" @@ -94,10 +96,6 @@ func (p *testPage) LinkTitle() string { return p.linkTitle } -func (p *testPage) Path() string { - return p.path -} - func (p *testPage) SectionsPath() string { panic("not implemented") } @@ -194,10 +192,6 @@ func (p *testPage) GetPageUpdater() PageUpdater { return PageUpdater{} } -func (p *testPage) Section() string { - panic("not implemented") -} - func (p *testPage) Type() string { panic("not implemented") } @@ -261,3 +255,81 @@ func (p *testPage) IsDescendant(other interface{}) (bool, error) { func (p *testPage) IsAncestor(other interface{}) (bool, error) { panic("not implemented") } + +func (p *testPage) Next() Page { + panic("not implemented") +} + +func (p *testPage) Prev() Page { + panic("not implemented") +} + +func (p *testPage) WordCount() int { + panic("not implemented") +} + +func (p *testPage) FuzzyWordCount() int { + panic("not implemented") +} + +func (p *testPage) ReadingTime() int { + panic("not implemented") +} + +func (p *testPage) Summary() template.HTML { + panic("not implemented") +} + +// File + +func (p *testPage) Filename() string { + panic("not implemented") +} + +func (p *testPage) Path() string { + return p.path +} + +func (p *testPage) Dir() string { + panic("not implemented") +} + +func (p *testPage) Extension() string { + panic("not implemented") +} + +func (p *testPage) Ext() string { + panic("not implemented") +} + +func (p *testPage) Lang() string { + panic("not implemented") +} + +func (p *testPage) LogicalName() string { + panic("not implemented") +} + +func (p *testPage) Section() string { + panic("not implemented") +} + +func (p *testPage) BaseFileName() string { + panic("not implemented") +} + +func (p *testPage) TranslationBaseName() string { + panic("not implemented") +} + +func (p *testPage) ContentBaseName() string { + panic("not implemented") +} + +func (p *testPage) UniqueID() string { + panic("not implemented") +} + +func (p *testPage) FileInfo() os.FileInfo { + panic("not implemented") +}