diff options
Diffstat (limited to 'hugolib/integrationtest_builder.go')
-rw-r--r-- | hugolib/integrationtest_builder.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go index b593cd965..7a6c040b1 100644 --- a/hugolib/integrationtest_builder.go +++ b/hugolib/integrationtest_builder.go @@ -25,6 +25,7 @@ import ( "github.com/gohugoio/hugo/common/hexec" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/maps" + "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/config/allconfig" "github.com/gohugoio/hugo/config/security" @@ -466,6 +467,28 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder { return s } +func (s *IntegrationTestBuilder) BuildPartial(urls ...string) *IntegrationTestBuilder { + if _, err := s.BuildPartialE(urls...); err != nil { + s.Fatal(err) + } + return s +} + +func (s *IntegrationTestBuilder) BuildPartialE(urls ...string) (*IntegrationTestBuilder, error) { + if s.buildCount == 0 { + panic("BuildPartial can only be used after a full build") + } + if !s.Cfg.Running { + panic("BuildPartial can only be used in server mode") + } + visited := types.NewEvictingStringQueue(len(urls)) + for _, url := range urls { + visited.Add(url) + } + buildCfg := BuildCfg{RecentlyVisited: visited, PartialReRender: true} + return s, s.build(buildCfg) +} + func (s *IntegrationTestBuilder) Close() { s.Helper() s.Assert(s.H.Close(), qt.IsNil) @@ -747,10 +770,6 @@ func (s *IntegrationTestBuilder) build(cfg BuildCfg) error { s.counters = &buildCounters{} cfg.testCounters = s.counters - if s.buildCount > 0 && (len(changeEvents) == 0) { - return nil - } - s.buildCount++ err := s.H.Build(cfg, changeEvents...) |