@@ -228,6 +228,49 @@ func TestDriveSyncPushRejectsSymlinksBeforeAuthentication(t *testing.T) {
228228 }
229229}
230230
231+ func TestDriveSyncPushFindsExistingFileOnLaterPage (t * testing.T ) {
232+ root := t .TempDir ()
233+ if err := os .WriteFile (filepath .Join (root , "session.jsonl" ), []byte ("same" ), 0o600 ); err != nil {
234+ t .Fatal (err )
235+ }
236+
237+ mutations := 0
238+ pages := 0
239+ svc , closeServer := newDriveTestService (t , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
240+ switch {
241+ case r .Method == http .MethodGet && strings .HasSuffix (r .URL .Path , "/files/destination" ):
242+ _ = json .NewEncoder (w ).Encode (map [string ]any {"id" : "destination" , "mimeType" : driveMimeFolder })
243+ case r .Method == http .MethodGet && strings .HasSuffix (r .URL .Path , "/files" ):
244+ requireSupportsAllDrives (t , r )
245+ pages ++
246+ if r .URL .Query ().Get ("pageToken" ) == "page-2" {
247+ _ = json .NewEncoder (w ).Encode (map [string ]any {"files" : []map [string ]any {
248+ {"id" : "session-id" , "name" : "session.jsonl" , "mimeType" : "application/json" , "size" : "4" , "md5Checksum" : "51037a4a37730f52c8732586d3aaa316" },
249+ }})
250+ return
251+ }
252+ _ = json .NewEncoder (w ).Encode (map [string ]any {"files" : []any {}, "nextPageToken" : "page-2" })
253+ default :
254+ mutations ++
255+ http .Error (w , "unexpected mutation" , http .StatusInternalServerError )
256+ }
257+ }))
258+ defer closeServer ()
259+
260+ result := executeWithDriveTestService (t , []string {
261+ "--json" ,
"--account" ,
"[email protected] " ,
"drive" ,
"sync" ,
"push" ,
root ,
"--parent" ,
"destination" ,
262+ }, svc )
263+ if result .err != nil {
264+ t .Fatalf ("drive sync push: %v" , result .err )
265+ }
266+ if pages != 2 || mutations != 0 {
267+ t .Fatalf ("expected two read pages and no mutations, pages=%d mutations=%d" , pages , mutations )
268+ }
269+ if ! strings .Contains (result .stdout , `"skipped": 1` ) {
270+ t .Fatalf ("unexpected result: %s" , result .stdout )
271+ }
272+ }
273+
231274func TestDriveSyncPushStressPlansLargeTreeDeterministically (t * testing.T ) {
232275 root := t .TempDir ()
233276 const folders = 20
0 commit comments