summaryrefslogtreecommitdiffstats
path: root/hugolib/site_test.go
diff options
context:
space:
mode:
authorHanchen Wang <hanchen.wang@mail.utoronto.ca>2016-05-11 10:04:53 -0400
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-06-14 15:45:25 +0200
commitd4156e61277f4a006670a9eb1acba8b98140c5ef (patch)
tree5ac64826869f992065854bfeb26b63ff6d054c91 /hugolib/site_test.go
parent2564f46a685704c459bec5d0100f5111c138c9b4 (diff)
hugolib: Support an expiration date
Diffstat (limited to 'hugolib/site_test.go')
-rw-r--r--hugolib/site_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/hugolib/site_test.go b/hugolib/site_test.go
index f0c7a8e2d..4e68b5ff8 100644
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -296,6 +296,48 @@ func TestDraftAndFutureRender(t *testing.T) {
viper.Set("BuildFuture", false)
}
+func TestFutureExpirationRender(t *testing.T) {
+ viper.Reset()
+ defer viper.Reset()
+
+ hugofs.InitMemFs()
+ sources := []source.ByteSource{
+ {filepath.FromSlash("sect/doc3.md"), []byte("---\ntitle: doc1\nexpirydate: \"2400-05-29\"\n---\n# doc1\n*some content*")},
+ {filepath.FromSlash("sect/doc4.md"), []byte("---\ntitle: doc2\nexpirydate: \"2000-05-29\"\n---\n# doc2\n*some content*")},
+ }
+
+ siteSetup := func() *Site {
+ s := &Site{
+ Source: &source.InMemorySource{ByteSource: sources},
+ }
+
+ s.initializeSiteInfo()
+
+ if err := s.createPages(); err != nil {
+ t.Fatalf("Unable to create pages: %s", err)
+ }
+ return s
+ }
+
+ viper.Set("baseurl", "http://auth/bub")
+
+ s := siteSetup()
+
+ if len(s.Pages) != 1 {
+ if len(s.Pages) > 1 {
+ t.Fatal("Expired content published unexpectedly")
+ }
+
+ if len(s.Pages) < 1 {
+ t.Fatal("Valid content expired unexpectedly")
+ }
+ }
+
+ if s.Pages[0].Title == "doc2" {
+ t.Fatal("Expired content published unexpectedly")
+ }
+}
+
// Issue #957
func TestCrossrefs(t *testing.T) {
hugofs.InitMemFs()