@@ -23,13 +23,12 @@ import (
23
23
24
24
func TestRequest (t * testing.T ) {
25
25
t .Parallel ()
26
- now := time .Now ()
27
26
codec := InstantQueryCodec
28
27
29
28
for _ , tc := range []struct {
30
29
url string
31
30
expectedURL string
32
- expected tripperware. Request
31
+ expected * PrometheusRequest
33
32
expectedErr error
34
33
}{
35
34
{
@@ -60,10 +59,10 @@ func TestRequest(t *testing.T) {
60
59
},
61
60
{
62
61
url : "/api/v1/query?query=sum%28container_memory_rss%29+by+%28namespace%29" ,
63
- expectedURL : fmt . Sprintf ( "%s%d" , " /api/v1/query?query=sum%28container_memory_rss%29+by+%28namespace%29&time=", now . Unix ()) ,
62
+ expectedURL : " /api/v1/query?query=sum%28container_memory_rss%29+by+%28namespace%29&time=" ,
64
63
expected : & PrometheusRequest {
65
64
Path : "/api/v1/query" ,
66
- Time : now . Unix () * 1e3 ,
65
+ Time : 0 ,
67
66
Query : "sum(container_memory_rss) by (namespace)" ,
68
67
Stats : "" ,
69
68
Headers : map [string ][]string {
@@ -84,6 +83,11 @@ func TestRequest(t *testing.T) {
84
83
// Get a deep copy of the request with Context changed to ctx
85
84
r = r .Clone (ctx )
86
85
86
+ if tc .expected .Time == 0 {
87
+ now := time .Now ()
88
+ tc .expectedURL = fmt .Sprintf ("%s%d" , tc .expectedURL , now .Unix ())
89
+ tc .expected .Time = now .Unix () * 1e3
90
+ }
87
91
req , err := codec .DecodeRequest (ctx , r , []string {"Test-Header" })
88
92
if err != nil {
89
93
require .EqualValues (t , tc .expectedErr , err )
0 commit comments