|
7 | 7 | "testing" |
8 | 8 | "time" |
9 | 9 |
|
| 10 | + "github.com/convox/rack/pkg/helpers" |
10 | 11 | "github.com/convox/rack/pkg/options" |
11 | 12 | "github.com/convox/rack/pkg/structs" |
12 | 13 | "github.com/convox/rack/pkg/test/awsutil" |
@@ -108,22 +109,32 @@ func TestAppLogs(t *testing.T) { |
108 | 109 | } |
109 | 110 |
|
110 | 111 | func TestAppLogsSince(t *testing.T) { |
| 112 | + oldNow := helpers.TimeNow |
| 113 | + helpers.TimeNow = func() time.Time { |
| 114 | + return time.Date(2025, 4, 9, 22, 0, 0, 0, time.UTC) |
| 115 | + } |
| 116 | + defer func() { helpers.TimeNow = oldNow }() |
| 117 | + |
| 118 | + mockedNow := helpers.TimeNow() |
| 119 | + wantThen := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC) |
| 120 | + |
| 121 | + since := mockedNow.Sub(wantThen) |
| 122 | + |
111 | 123 | provider := StubAwsProvider( |
112 | 124 | cycleListAppStackResources, |
113 | 125 | cycleLogFilterLogEventsLimit1, |
114 | 126 | cycleLogFilterLogEventsLimit2, |
115 | 127 | ) |
116 | 128 | defer provider.Close() |
117 | 129 |
|
118 | | - buf := &bytes.Buffer{} |
119 | | - |
120 | 130 | r, err := provider.AppLogs("httpd", structs.LogsOptions{ |
121 | 131 | Follow: options.Bool(false), |
122 | 132 | Filter: options.String("test"), |
123 | 133 | Prefix: options.Bool(true), |
124 | | - Since: options.Duration(time.Since(time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC))), |
| 134 | + Since: options.Duration(since), |
125 | 135 | }) |
126 | 136 |
|
| 137 | + buf := &bytes.Buffer{} |
127 | 138 | io.Copy(buf, r) |
128 | 139 |
|
129 | 140 | assert.NoError(t, err) |
@@ -339,9 +350,9 @@ var cycleLogFilterLogEventsLimit1 = awsutil.Cycle{ |
339 | 350 | ], |
340 | 351 | "searchedLogStreams": [ |
341 | 352 | { |
342 | | - "searchedCompletely": false, |
| 353 | + "searchedCompletely": false, |
343 | 354 | "logStreamName": "stream1" |
344 | | - }, |
| 355 | + }, |
345 | 356 | { |
346 | 357 | "searchedCompletely": false, |
347 | 358 | "logStreamName": "stream2" |
@@ -385,9 +396,9 @@ var cycleLogFilterLogEventsLimit2 = awsutil.Cycle{ |
385 | 396 | ], |
386 | 397 | "searchedLogStreams": [ |
387 | 398 | { |
388 | | - "searchedCompletely": true, |
| 399 | + "searchedCompletely": true, |
389 | 400 | "logStreamName": "stream1" |
390 | | - }, |
| 401 | + }, |
391 | 402 | { |
392 | 403 | "searchedCompletely": false, |
393 | 404 | "logStreamName": "stream2" |
@@ -436,9 +447,9 @@ var cycleLogFilterLogEvents1 = awsutil.Cycle{ |
436 | 447 | ], |
437 | 448 | "searchedLogStreams": [ |
438 | 449 | { |
439 | | - "searchedCompletely": false, |
| 450 | + "searchedCompletely": false, |
440 | 451 | "logStreamName": "stream1" |
441 | | - }, |
| 452 | + }, |
442 | 453 | { |
443 | 454 | "searchedCompletely": false, |
444 | 455 | "logStreamName": "stream2" |
@@ -486,9 +497,9 @@ var cycleLogFilterLogEvents2 = awsutil.Cycle{ |
486 | 497 | ], |
487 | 498 | "searchedLogStreams": [ |
488 | 499 | { |
489 | | - "searchedCompletely": true, |
| 500 | + "searchedCompletely": true, |
490 | 501 | "logStreamName": "stream1" |
491 | | - }, |
| 502 | + }, |
492 | 503 | { |
493 | 504 | "searchedCompletely": false, |
494 | 505 | "logStreamName": "stream2" |
|
0 commit comments