mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 13:28:25 +00:00 
			
		
		
		
	Estimated time represented in hours it might be convenient to have tracked time represented in the same way to be compared and managed. --------- Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
		
			
				
	
	
		
			26 lines
		
	
	
		
			737 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			737 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2022 Gitea. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package util
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/stretchr/testify/assert"
 | 
						|
)
 | 
						|
 | 
						|
func TestSecToHours(t *testing.T) {
 | 
						|
	second := int64(1)
 | 
						|
	minute := 60 * second
 | 
						|
	hour := 60 * minute
 | 
						|
	day := 24 * hour
 | 
						|
 | 
						|
	assert.Equal(t, "1 minute", SecToHours(minute+6*second))
 | 
						|
	assert.Equal(t, "1 hour", SecToHours(hour))
 | 
						|
	assert.Equal(t, "1 hour", SecToHours(hour+second))
 | 
						|
	assert.Equal(t, "14 hours 33 minutes", SecToHours(14*hour+33*minute+30*second))
 | 
						|
	assert.Equal(t, "156 hours 30 minutes", SecToHours(6*day+12*hour+30*minute+18*second))
 | 
						|
	assert.Equal(t, "98 hours 16 minutes", SecToHours(4*day+2*hour+16*minute+58*second))
 | 
						|
	assert.Equal(t, "672 hours", SecToHours(4*7*day))
 | 
						|
}
 |