mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-15 11:52:14 +01:00
huge refactoring
This commit is contained in:
6
internal/pkg/xtime/doc.go
Normal file
6
internal/pkg/xtime/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
Package xtime helps generating
|
||||
time.Duration from seconds represented
|
||||
as float64.
|
||||
*/
|
||||
package xtime
|
||||
10
internal/pkg/xtime/xtime.go
Normal file
10
internal/pkg/xtime/xtime.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package xtime
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Duration creates a time.Duration from seconds.
|
||||
func Duration(seconds float64) time.Duration {
|
||||
return time.Duration(1000*seconds) * time.Millisecond
|
||||
}
|
||||
14
internal/pkg/xtime/xtime_test.go
Normal file
14
internal/pkg/xtime/xtime_test.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package xtime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDuration(t *testing.T) {
|
||||
expected := time.Duration(1500) * time.Millisecond
|
||||
result := Duration(1.5)
|
||||
assert.Equal(t, expected.String(), result.String())
|
||||
}
|
||||
Reference in New Issue
Block a user