MCPcopy
hub / github.com/prometheus/client_golang / TestRetryAfterDuration

Function TestRetryAfterDuration

exp/api/remote/remote_api_test.go:37–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35)
36
37func TestRetryAfterDuration(t *testing.T) {
38 tc := []struct {
39 name string
40 tInput string
41 expected model.Duration
42 }{
43 {
44 name: "seconds",
45 tInput: "120",
46 expected: model.Duration(time.Second * 120),
47 },
48 {
49 name: "date-time default",
50 tInput: time.RFC1123, // Expected layout is http.TimeFormat, hence an error.
51 expected: 0,
52 },
53 {
54 name: "retry-after not provided",
55 tInput: "", // Expected layout is http.TimeFormat, hence an error.
56 expected: 0,
57 },
58 }
59 for _, c := range tc {
60 if got := retryAfterDuration(c.tInput); got != time.Duration(c.expected) {
61 t.Fatal("expected", c.expected, "got", got)
62 }
63 }
64}
65
66type mockStorage struct {
67 v2Reqs []*writev2.Request

Callers

nothing calls this directly

Calls 1

retryAfterDurationFunction · 0.85

Tested by

no test coverage detected