hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit a0b3d9db1689ea69ea5c23915df5b07d4fd9bb5c
parent 2ea242d5fe9c6f285e4b68ac2fd7258d2d3416e9
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Sun, 19 Feb 2017 13:18:04 +0100

hugolib: Add temporary date parse test

To debug the irregular Windows test failure.

See #3059

Diffstat:
Mhugolib/page_time_integration_test.go | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)
diff --git 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()
+
+}