Skip to content

Commit

Permalink
Update tests to match new time format
Browse files Browse the repository at this point in the history
  • Loading branch information
schorsch13 committed Feb 24, 2022
1 parent 2a0c27f commit 62e4424
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions models/issue_tracked_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAddTime(t *testing.T) {
assert.Equal(t, int64(3661), tt.Time)

comment := unittest.AssertExistsAndLoadBean(t, &Comment{Type: CommentTypeAddTimeManual, PosterID: 3, IssueID: 1}).(*Comment)
assert.Equal(t, comment.Content, "1h 1m 1s")
assert.Equal(t, comment.Content, "1 hour 1 minute")
}

func TestGetTrackedTimes(t *testing.T) {
Expand Down Expand Up @@ -86,17 +86,17 @@ func TestTotalTimes(t *testing.T) {
assert.Len(t, total, 1)
for user, time := range total {
assert.Equal(t, int64(1), user.ID)
assert.Equal(t, "6m 40s", time)
assert.Equal(t, "6 minutes 40 seconds", time)
}

total, err = TotalTimes(&FindTrackedTimesOptions{IssueID: 2})
assert.NoError(t, err)
assert.Len(t, total, 2)
for user, time := range total {
if user.ID == 2 {
assert.Equal(t, "1h 1m 2s", time)
assert.Equal(t, "1 hour 1 minute", time)
} else if user.ID == 1 {
assert.Equal(t, "20s", time)
assert.Equal(t, "20 seconds", time)
} else {
assert.Error(t, assert.AnError)
}
Expand All @@ -107,7 +107,7 @@ func TestTotalTimes(t *testing.T) {
assert.Len(t, total, 1)
for user, time := range total {
assert.Equal(t, int64(2), user.ID)
assert.Equal(t, "1s", time)
assert.Equal(t, "1 second", time)
}

total, err = TotalTimes(&FindTrackedTimesOptions{IssueID: 4})
Expand Down
2 changes: 1 addition & 1 deletion models/migrations/v210.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

"code.gitea.io/gitea/modules/timeutil"
"github.com/tstranex/u2f"

"github.com/tstranex/u2f"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
Expand Down
1 change: 1 addition & 0 deletions models/migrations/v210_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"code.gitea.io/gitea/modules/timeutil"

"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
)
Expand Down
2 changes: 1 addition & 1 deletion modules/util/sec_to_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func SecToTime(duration int64) string {
// formattedTime = "1 year"
// input: value = 3, name = "month"
// output will be "1 year 3 months"
func FormatTime(value int64, name string, formattedTime string) string {
func FormatTime(value int64, name, formattedTime string) string {
if value == 1 {
formattedTime = fmt.Sprintf("%s1 %s ", formattedTime, name)
} else if value > 1 {
Expand Down

0 comments on commit 62e4424

Please sign in to comment.