@@ -262,27 +262,31 @@ func TestFromLogEntry(t *testing.T) {
262262}
263263
264264func TestListLogEntriesRequest (t * testing.T ) {
265+ dayAgo := time .Now ().Add (- 24 * time .Hour ).UTC ().Format (time .RFC3339 )
265266 for _ , test := range []struct {
266267 opts []EntriesOption
267268 resourceNames []string
268269 filter string
269270 orderBy string
270271 }{
271- // Default is client's project ID, empty filter and orderBy.
272- {nil , []string {"projects/PROJECT_ID" }, "" , "" },
272+ // Default is client's project ID, 24 hour lookback, and orderBy.
273+ {nil , []string {"projects/PROJECT_ID" }, `timestamp >= "` + dayAgo + `"` , "" },
274+ // Timestamp default does not override user's filter
275+ {[]EntriesOption {NewestFirst (), Filter (`timestamp > "2020-10-30T15:39:09Z"` )},
276+ []string {"projects/PROJECT_ID" }, `timestamp > "2020-10-30T15:39:09Z"` , "timestamp desc" },
273277 {[]EntriesOption {NewestFirst (), Filter ("f" )},
274- []string {"projects/PROJECT_ID" }, "f" , "timestamp desc" },
278+ []string {"projects/PROJECT_ID" }, `f AND timestamp >= "` + dayAgo + `"` , "timestamp desc" },
275279 {[]EntriesOption {ProjectIDs ([]string {"foo" })},
276- []string {"projects/foo" }, "" , "" },
280+ []string {"projects/foo" }, `timestamp >= "` + dayAgo + `"` , "" },
277281 {[]EntriesOption {ResourceNames ([]string {"folders/F" , "organizations/O" })},
278- []string {"folders/F" , "organizations/O" }, "" , "" },
282+ []string {"folders/F" , "organizations/O" }, `timestamp >= "` + dayAgo + `"` , "" },
279283 {[]EntriesOption {NewestFirst (), Filter ("f" ), ProjectIDs ([]string {"foo" })},
280- []string {"projects/foo" }, "f" , "timestamp desc" },
284+ []string {"projects/foo" }, `f AND timestamp >= "` + dayAgo + `"` , "timestamp desc" },
281285 {[]EntriesOption {NewestFirst (), Filter ("f" ), ProjectIDs ([]string {"foo" })},
282- []string {"projects/foo" }, "f" , "timestamp desc" },
286+ []string {"projects/foo" }, `f AND timestamp >= "` + dayAgo + `"` , "timestamp desc" },
283287 // If there are repeats, last one wins.
284288 {[]EntriesOption {NewestFirst (), Filter ("no" ), ProjectIDs ([]string {"foo" }), Filter ("f" )},
285- []string {"projects/foo" }, "f" , "timestamp desc" },
289+ []string {"projects/foo" }, `f AND timestamp >= "` + dayAgo + `"` , "timestamp desc" },
286290 } {
287291 got := listLogEntriesRequest ("projects/PROJECT_ID" , test .opts )
288292 want := & logpb.ListLogEntriesRequest {
0 commit comments