mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:08:31 +02:00
feat(serialization): add 'd', 'w',' 'M' units support for time duration
- Updated Makefile to include `-checklinkname=0` in LDFLAGS
This commit is contained in:
16
internal/serialization/time_test.go
Normal file
16
internal/serialization/time_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package serialization
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
expect "github.com/yusing/go-proxy/internal/utils/testing"
|
||||
)
|
||||
|
||||
// NOTE: -ldflags=-checklinkname=0 is required to test this function
|
||||
func TestParseDuration(t *testing.T) {
|
||||
require.Equal(t, 24*time.Hour, expect.Must(time.ParseDuration("1d")))
|
||||
require.Equal(t, 7*24*time.Hour, expect.Must(time.ParseDuration("1w")))
|
||||
require.Equal(t, 30*24*time.Hour, expect.Must(time.ParseDuration("1M")))
|
||||
}
|
||||
Reference in New Issue
Block a user