mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 04:20:55 +00:00
hugolib: Add temporary date parse test
To debug the irregular Windows test failure. See #3059
This commit is contained in:
parent
2ea242d5fe
commit
a0b3d9db16
1 changed files with 37 additions and 0 deletions
|
@ -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()
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue