Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Fix tests names so they are executed #75

Merged
merged 3 commits into from
Apr 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func TestDiffForHumansNowAndHours(t *testing.T) {
assert.Equal(t, "2 hours ago", gotTime)
}

func _TestDiffForHumansNowAndNearlyDayOne(t *testing.T) {
gotTime, err := Now().SubHours(743).DiffForHumans(nil, false, false, false)
func TestDiffForHumansNowAndNearlyDayOne(t *testing.T) {
gotTime, err := Now().SubWeeks(4).DiffForHumans(nil, false, false, false)
assert.Nil(t, err)
assert.Equal(t, "4 weeks ago", gotTime)
}
Expand Down Expand Up @@ -145,10 +145,7 @@ func TestDiffForHumansNowAndNearlyMonth(t *testing.T) {
}

func TestDiffForHumansNowAndMonth(t *testing.T) {
gotTime, err := Now().SubWeeks(4).DiffForHumans(nil, false, false, false)
assert.Nil(t, err)
assert.Equal(t, "4 weeks ago", gotTime)
gotTime, err = Now().SubMonth().DiffForHumans(nil, false, false, false)
gotTime, err := Now().SubMonth().DiffForHumans(nil, false, false, false)
assert.Nil(t, err)
assert.Equal(t, "1 month ago", gotTime)
}
Expand Down Expand Up @@ -525,8 +522,8 @@ func TestDiffForHumansOtherAndLessThanFutureMonth(t *testing.T) {
assert.Equal(t, "4 weeks after", gotTime)
}

func _TestDiffForHumansOtherAndFutureMonth(t *testing.T) {
gotTime, err := Now().DiffForHumans(Now().SubMonth(), true, false, false)
func TestDiffForHumansOtherAndFutureMonth(t *testing.T) {
gotTime, err := Now().AddMonth().DiffForHumans(Now(), true, false, false)
assert.Nil(t, err)
assert.Equal(t, "1 month after", gotTime)
}
Expand Down Expand Up @@ -565,6 +562,12 @@ func TestDiffForHumansAbsoluteSeconds(t *testing.T) {
assert.Equal(t, "59 seconds", gotTime2)
}

func TestDiffForOneMinute(t *testing.T) {
gotTime, err := Now().SubMinute().DiffForHumans(nil, false, false, false)
assert.Nil(t, err)
assert.Equal(t, "1 minute ago", gotTime)
}

func TestDiffForHumansAbsoluteMinutes(t *testing.T) {
gotTime, err := Now().DiffForHumans(Now().SubMinutes(30), true, true, false)
assert.Nil(t, err)
Expand All @@ -585,6 +588,16 @@ func TestDiffForHumansAbsoluteHours(t *testing.T) {
assert.Equal(t, "3 hours", gotTime2)
}

func TestForDiffInHours(t *testing.T) {
a := NewCarbon(time.Now())
b := NewCarbon(time.Now().Add(time.Hour * 10))

gotTime, err := a.DiffForHumans(b, false, false, false)

assert.Nil(t, err)
assert.Equal(t, "10 hours before", gotTime)
}

func TestDiffForHumansAbsoluteDays(t *testing.T) {
gotTime, err := Now().DiffForHumans(Now().SubDays(2), true, true, false)
assert.Nil(t, err)
Expand Down