Pallinder/go-randomdata

randomdata.FullDate() can return invalid dates

Closed this issue · 1 comments

I leverage the randomdata.FullDate() function call in some unit tests by parsing the random full dates into time.Time structs. :

			t, err = time.Parse(dateLayout, randomdata.FullDate())
			if err != nil {
				Fail(err.Error())
			}

What I expected to see : The above fail handler would not be called

What I actually saw : parsing time "Tuesday 29 Feb 2018": day out of range

This causes intermittent unit test failures.

Since it's intermittent, there aren't steps to reproduce. I think it can be fixed by regenerating the random date if time.Parse returns an error. Simple and only depends on standard library. If I get a chance this week, I'll submit a PR.