aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorRené Schaar <rene@schaar.priv.at>2022-02-28 23:57:20 +0100
committerGitHub <noreply@github.com>2022-02-28 23:57:20 +0100
commit6859b6919800cbf2958dbfbe76fca42f4dcbb194 (patch)
treef9c4e85d80ac78d73dfd4f0d5789084823f0695d /models
parentb75ad7b87f122a1386cb0e576ce83cc000f6d010 (diff)
downloadgitea-6859b6919800cbf2958dbfbe76fca42f4dcbb194.tar.gz
gitea-6859b6919800cbf2958dbfbe76fca42f4dcbb194.zip
Refactor SecToTime() function (#18863)
- Add helper method to reduce redundancy - Expand the scope from displaying days to years - Reduce irrelevance by not displaying small units (hours, minutes, seconds) when bigger ones apply (years)
Diffstat (limited to 'models')
-rw-r--r--models/issue_tracked_time_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/issue_tracked_time_test.go b/models/issue_tracked_time_test.go
index e6c9caf900..68e78c71c7 100644
--- a/models/issue_tracked_time_test.go
+++ b/models/issue_tracked_time_test.go
@@ -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) {
@@ -86,7 +86,7 @@ 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})
@@ -94,9 +94,9 @@ func TestTotalTimes(t *testing.T) {
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)
}
@@ -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})