hugolib: Add temporary date parse test

To debug the irregular Windows test failure.

See #3059
This commit is contained in:
Bjørn Erik Pedersen 2017-02-19 13:18:04 +01:00
parent 2ea242d5fe
commit a0b3d9db16

View file

@ -17,8 +17,11 @@ import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
"sync"
"testing" "testing"
"time" "time"
"github.com/spf13/cast"
) )
const ( 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()
}