Files
zeekayandHanzo Dev b726a55cab cd: internalize the five argoproj/pkg utilities, drop the dependency
github.com/argoproj/pkg/v2 was one of two live argoproj dependencies. It is
11 files and 176K total, and we used five packages from it: grpc/http,
kubeclientmetrics, stats, sync, time.

Vendored into util/vendored/ and the dependency dropped from go.mod, so the
gRPC surface (2 references, in grpc-http/forwarders.go) is now ours to remove
on our own schedule rather than upstream's. Kubernetes client-go pulls gRPC
transitively regardless, so this is isolation — a realistic first step — not
a claim that gRPC is gone.

Internalized rather than forked to a shared repo because the only other
consumer, hanzo/gitops, has zero live deployments and zero dependents. A
second repo would be a second thing to version for one caller.

NOTICE carries the Apache-2.0 attribution. go build ./... exit 0.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-28 16:08:34 -07:00

42 lines
957 B
Go

package time
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestParseDuration tests TestParseDuration
func TestParseDuration(t *testing.T) {
type testData struct {
duration string
xVal time.Duration
}
testdata := []testData{
{"1s", time.Second},
{"10s", 10 * time.Second},
{"60s", time.Minute},
{"1m", time.Minute},
{"1h", time.Hour},
{"1d", 24 * time.Hour},
{"2d", 48 * time.Hour},
}
for _, data := range testdata {
dur, err := ParseDuration(data.duration)
require.NoError(t, err)
assert.Equal(t, dur.Nanoseconds(), data.xVal.Nanoseconds())
}
_, err := ParseDuration("1z")
assert.Error(t, err)
}
// TestParseSince tests parsing of since strings
func TestParseSince(t *testing.T) {
oneDayAgo, err := ParseSince("1d")
require.NoError(t, err)
yesterday := time.Now().UTC().Add(-24 * time.Hour)
assert.Equal(t, yesterday.Minute(), oneDayAgo.Minute())
}