summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hugolib/page_time_integration_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/hugolib/page_time_integration_test.go b/hugolib/page_time_integration_test.go
index dde1587dd..534933d2b 100644
--- a/hugolib/page_time_integration_test.go
+++ b/hugolib/page_time_integration_test.go
@@ -17,8 +17,11 @@ import (
"fmt"
"os"
"strings"
+ "sync"
"testing"
"time"
+
+ "github.com/spf13/cast"
)
const (
@@ -144,3 +147,37 @@ func TestParsingDateInFrontMatter(t *testing.T) {
}
}
}
+
+// Temp test https://github.com/spf13/hugo/issues/3059
+func TestParsingDateParallel(t *testing.T) {
+ t.Parallel()
+
+ var wg sync.WaitGroup
+
+ for j := 0; j < 100; j++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for j := 0; j < 100; j++ {
+ dateStr := "2010-05-02 15:29:31 +08:00"
+
+ dt, err := time.Parse("2006-01-02 15:04:05 -07:00", dateStr)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if dt.Year() != 2010 {
+ t.Fatal("time.Parse: Invalid date:", dt)
+ }
+
+ dt2 := cast.ToTime(dateStr)
+
+ if dt2.Year() != 2010 {
+ t.Fatal("cast.ToTime: Invalid date:", dt2.Year())
+ }
+ }
+ }()
+ }
+ wg.Wait()
+
+}