...

Text file src/go.mongodb.org/mongo-driver/testdata/gridfs/delete.json

Documentation: go.mongodb.org/mongo-driver/testdata/gridfs

     1{
     2  "description": "gridfs-delete",
     3  "schemaVersion": "1.0",
     4  "createEntities": [
     5    {
     6      "client": {
     7        "id": "client0"
     8      }
     9    },
    10    {
    11      "database": {
    12        "id": "database0",
    13        "client": "client0",
    14        "databaseName": "gridfs-tests"
    15      }
    16    },
    17    {
    18      "bucket": {
    19        "id": "bucket0",
    20        "database": "database0"
    21      }
    22    },
    23    {
    24      "collection": {
    25        "id": "bucket0_files_collection",
    26        "database": "database0",
    27        "collectionName": "fs.files"
    28      }
    29    },
    30    {
    31      "collection": {
    32        "id": "bucket0_chunks_collection",
    33        "database": "database0",
    34        "collectionName": "fs.chunks"
    35      }
    36    }
    37  ],
    38  "initialData": [
    39    {
    40      "collectionName": "fs.files",
    41      "databaseName": "gridfs-tests",
    42      "documents": [
    43        {
    44          "_id": {
    45            "$oid": "000000000000000000000001"
    46          },
    47          "length": 0,
    48          "chunkSize": 4,
    49          "uploadDate": {
    50            "$date": "1970-01-01T00:00:00.000Z"
    51          },
    52          "md5": "d41d8cd98f00b204e9800998ecf8427e",
    53          "filename": "length-0",
    54          "contentType": "application/octet-stream",
    55          "aliases": [],
    56          "metadata": {}
    57        },
    58        {
    59          "_id": {
    60            "$oid": "000000000000000000000002"
    61          },
    62          "length": 0,
    63          "chunkSize": 4,
    64          "uploadDate": {
    65            "$date": "1970-01-01T00:00:00.000Z"
    66          },
    67          "md5": "d41d8cd98f00b204e9800998ecf8427e",
    68          "filename": "length-0-with-empty-chunk",
    69          "contentType": "application/octet-stream",
    70          "aliases": [],
    71          "metadata": {}
    72        },
    73        {
    74          "_id": {
    75            "$oid": "000000000000000000000003"
    76          },
    77          "length": 2,
    78          "chunkSize": 4,
    79          "uploadDate": {
    80            "$date": "1970-01-01T00:00:00.000Z"
    81          },
    82          "md5": "c700ed4fdb1d27055aa3faa2c2432283",
    83          "filename": "length-2",
    84          "contentType": "application/octet-stream",
    85          "aliases": [],
    86          "metadata": {}
    87        },
    88        {
    89          "_id": {
    90            "$oid": "000000000000000000000004"
    91          },
    92          "length": 8,
    93          "chunkSize": 4,
    94          "uploadDate": {
    95            "$date": "1970-01-01T00:00:00.000Z"
    96          },
    97          "md5": "dd254cdc958e53abaa67da9f797125f5",
    98          "filename": "length-8",
    99          "contentType": "application/octet-stream",
   100          "aliases": [],
   101          "metadata": {}
   102        }
   103      ]
   104    },
   105    {
   106      "collectionName": "fs.chunks",
   107      "databaseName": "gridfs-tests",
   108      "documents": [
   109        {
   110          "_id": {
   111            "$oid": "000000000000000000000001"
   112          },
   113          "files_id": {
   114            "$oid": "000000000000000000000002"
   115          },
   116          "n": 0,
   117          "data": {
   118            "$binary": {
   119              "base64": "",
   120              "subType": "00"
   121            }
   122          }
   123        },
   124        {
   125          "_id": {
   126            "$oid": "000000000000000000000002"
   127          },
   128          "files_id": {
   129            "$oid": "000000000000000000000003"
   130          },
   131          "n": 0,
   132          "data": {
   133            "$binary": {
   134              "base64": "ESI=",
   135              "subType": "00"
   136            }
   137          }
   138        },
   139        {
   140          "_id": {
   141            "$oid": "000000000000000000000003"
   142          },
   143          "files_id": {
   144            "$oid": "000000000000000000000004"
   145          },
   146          "n": 0,
   147          "data": {
   148            "$binary": {
   149              "base64": "ESIzRA==",
   150              "subType": "00"
   151            }
   152          }
   153        },
   154        {
   155          "_id": {
   156            "$oid": "000000000000000000000004"
   157          },
   158          "files_id": {
   159            "$oid": "000000000000000000000004"
   160          },
   161          "n": 1,
   162          "data": {
   163            "$binary": {
   164              "base64": "VWZ3iA==",
   165              "subType": "00"
   166            }
   167          }
   168        }
   169      ]
   170    }
   171  ],
   172  "tests": [
   173    {
   174      "description": "delete when length is 0",
   175      "operations": [
   176        {
   177          "name": "delete",
   178          "object": "bucket0",
   179          "arguments": {
   180            "id": {
   181              "$oid": "000000000000000000000001"
   182            }
   183          }
   184        }
   185      ],
   186      "outcome": [
   187        {
   188          "collectionName": "fs.files",
   189          "databaseName": "gridfs-tests",
   190          "documents": [
   191            {
   192              "_id": {
   193                "$oid": "000000000000000000000002"
   194              },
   195              "length": 0,
   196              "chunkSize": 4,
   197              "uploadDate": {
   198                "$date": "1970-01-01T00:00:00.000Z"
   199              },
   200              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   201              "filename": "length-0-with-empty-chunk",
   202              "contentType": "application/octet-stream",
   203              "aliases": [],
   204              "metadata": {}
   205            },
   206            {
   207              "_id": {
   208                "$oid": "000000000000000000000003"
   209              },
   210              "length": 2,
   211              "chunkSize": 4,
   212              "uploadDate": {
   213                "$date": "1970-01-01T00:00:00.000Z"
   214              },
   215              "md5": "c700ed4fdb1d27055aa3faa2c2432283",
   216              "filename": "length-2",
   217              "contentType": "application/octet-stream",
   218              "aliases": [],
   219              "metadata": {}
   220            },
   221            {
   222              "_id": {
   223                "$oid": "000000000000000000000004"
   224              },
   225              "length": 8,
   226              "chunkSize": 4,
   227              "uploadDate": {
   228                "$date": "1970-01-01T00:00:00.000Z"
   229              },
   230              "md5": "dd254cdc958e53abaa67da9f797125f5",
   231              "filename": "length-8",
   232              "contentType": "application/octet-stream",
   233              "aliases": [],
   234              "metadata": {}
   235            }
   236          ]
   237        },
   238        {
   239          "collectionName": "fs.chunks",
   240          "databaseName": "gridfs-tests",
   241          "documents": [
   242            {
   243              "_id": {
   244                "$oid": "000000000000000000000001"
   245              },
   246              "files_id": {
   247                "$oid": "000000000000000000000002"
   248              },
   249              "n": 0,
   250              "data": {
   251                "$binary": {
   252                  "base64": "",
   253                  "subType": "00"
   254                }
   255              }
   256            },
   257            {
   258              "_id": {
   259                "$oid": "000000000000000000000002"
   260              },
   261              "files_id": {
   262                "$oid": "000000000000000000000003"
   263              },
   264              "n": 0,
   265              "data": {
   266                "$binary": {
   267                  "base64": "ESI=",
   268                  "subType": "00"
   269                }
   270              }
   271            },
   272            {
   273              "_id": {
   274                "$oid": "000000000000000000000003"
   275              },
   276              "files_id": {
   277                "$oid": "000000000000000000000004"
   278              },
   279              "n": 0,
   280              "data": {
   281                "$binary": {
   282                  "base64": "ESIzRA==",
   283                  "subType": "00"
   284                }
   285              }
   286            },
   287            {
   288              "_id": {
   289                "$oid": "000000000000000000000004"
   290              },
   291              "files_id": {
   292                "$oid": "000000000000000000000004"
   293              },
   294              "n": 1,
   295              "data": {
   296                "$binary": {
   297                  "base64": "VWZ3iA==",
   298                  "subType": "00"
   299                }
   300              }
   301            }
   302          ]
   303        }
   304      ]
   305    },
   306    {
   307      "description": "delete when length is 0 and there is one extra empty chunk",
   308      "operations": [
   309        {
   310          "name": "delete",
   311          "object": "bucket0",
   312          "arguments": {
   313            "id": {
   314              "$oid": "000000000000000000000002"
   315            }
   316          }
   317        }
   318      ],
   319      "outcome": [
   320        {
   321          "collectionName": "fs.files",
   322          "databaseName": "gridfs-tests",
   323          "documents": [
   324            {
   325              "_id": {
   326                "$oid": "000000000000000000000001"
   327              },
   328              "length": 0,
   329              "chunkSize": 4,
   330              "uploadDate": {
   331                "$date": "1970-01-01T00:00:00.000Z"
   332              },
   333              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   334              "filename": "length-0",
   335              "contentType": "application/octet-stream",
   336              "aliases": [],
   337              "metadata": {}
   338            },
   339            {
   340              "_id": {
   341                "$oid": "000000000000000000000003"
   342              },
   343              "length": 2,
   344              "chunkSize": 4,
   345              "uploadDate": {
   346                "$date": "1970-01-01T00:00:00.000Z"
   347              },
   348              "md5": "c700ed4fdb1d27055aa3faa2c2432283",
   349              "filename": "length-2",
   350              "contentType": "application/octet-stream",
   351              "aliases": [],
   352              "metadata": {}
   353            },
   354            {
   355              "_id": {
   356                "$oid": "000000000000000000000004"
   357              },
   358              "length": 8,
   359              "chunkSize": 4,
   360              "uploadDate": {
   361                "$date": "1970-01-01T00:00:00.000Z"
   362              },
   363              "md5": "dd254cdc958e53abaa67da9f797125f5",
   364              "filename": "length-8",
   365              "contentType": "application/octet-stream",
   366              "aliases": [],
   367              "metadata": {}
   368            }
   369          ]
   370        },
   371        {
   372          "collectionName": "fs.chunks",
   373          "databaseName": "gridfs-tests",
   374          "documents": [
   375            {
   376              "_id": {
   377                "$oid": "000000000000000000000002"
   378              },
   379              "files_id": {
   380                "$oid": "000000000000000000000003"
   381              },
   382              "n": 0,
   383              "data": {
   384                "$binary": {
   385                  "base64": "ESI=",
   386                  "subType": "00"
   387                }
   388              }
   389            },
   390            {
   391              "_id": {
   392                "$oid": "000000000000000000000003"
   393              },
   394              "files_id": {
   395                "$oid": "000000000000000000000004"
   396              },
   397              "n": 0,
   398              "data": {
   399                "$binary": {
   400                  "base64": "ESIzRA==",
   401                  "subType": "00"
   402                }
   403              }
   404            },
   405            {
   406              "_id": {
   407                "$oid": "000000000000000000000004"
   408              },
   409              "files_id": {
   410                "$oid": "000000000000000000000004"
   411              },
   412              "n": 1,
   413              "data": {
   414                "$binary": {
   415                  "base64": "VWZ3iA==",
   416                  "subType": "00"
   417                }
   418              }
   419            }
   420          ]
   421        }
   422      ]
   423    },
   424    {
   425      "description": "delete when length is 8",
   426      "operations": [
   427        {
   428          "name": "delete",
   429          "object": "bucket0",
   430          "arguments": {
   431            "id": {
   432              "$oid": "000000000000000000000004"
   433            }
   434          }
   435        }
   436      ],
   437      "outcome": [
   438        {
   439          "collectionName": "fs.files",
   440          "databaseName": "gridfs-tests",
   441          "documents": [
   442            {
   443              "_id": {
   444                "$oid": "000000000000000000000001"
   445              },
   446              "length": 0,
   447              "chunkSize": 4,
   448              "uploadDate": {
   449                "$date": "1970-01-01T00:00:00.000Z"
   450              },
   451              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   452              "filename": "length-0",
   453              "contentType": "application/octet-stream",
   454              "aliases": [],
   455              "metadata": {}
   456            },
   457            {
   458              "_id": {
   459                "$oid": "000000000000000000000002"
   460              },
   461              "length": 0,
   462              "chunkSize": 4,
   463              "uploadDate": {
   464                "$date": "1970-01-01T00:00:00.000Z"
   465              },
   466              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   467              "filename": "length-0-with-empty-chunk",
   468              "contentType": "application/octet-stream",
   469              "aliases": [],
   470              "metadata": {}
   471            },
   472            {
   473              "_id": {
   474                "$oid": "000000000000000000000003"
   475              },
   476              "length": 2,
   477              "chunkSize": 4,
   478              "uploadDate": {
   479                "$date": "1970-01-01T00:00:00.000Z"
   480              },
   481              "md5": "c700ed4fdb1d27055aa3faa2c2432283",
   482              "filename": "length-2",
   483              "contentType": "application/octet-stream",
   484              "aliases": [],
   485              "metadata": {}
   486            }
   487          ]
   488        },
   489        {
   490          "collectionName": "fs.chunks",
   491          "databaseName": "gridfs-tests",
   492          "documents": [
   493            {
   494              "_id": {
   495                "$oid": "000000000000000000000001"
   496              },
   497              "files_id": {
   498                "$oid": "000000000000000000000002"
   499              },
   500              "n": 0,
   501              "data": {
   502                "$binary": {
   503                  "base64": "",
   504                  "subType": "00"
   505                }
   506              }
   507            },
   508            {
   509              "_id": {
   510                "$oid": "000000000000000000000002"
   511              },
   512              "files_id": {
   513                "$oid": "000000000000000000000003"
   514              },
   515              "n": 0,
   516              "data": {
   517                "$binary": {
   518                  "base64": "ESI=",
   519                  "subType": "00"
   520                }
   521              }
   522            }
   523          ]
   524        }
   525      ]
   526    },
   527    {
   528      "description": "delete when files entry does not exist",
   529      "operations": [
   530        {
   531          "name": "delete",
   532          "object": "bucket0",
   533          "arguments": {
   534            "id": {
   535              "$oid": "000000000000000000000000"
   536            }
   537          },
   538          "expectError": {
   539            "isError": true
   540          }
   541        }
   542      ],
   543      "outcome": [
   544        {
   545          "collectionName": "fs.files",
   546          "databaseName": "gridfs-tests",
   547          "documents": [
   548            {
   549              "_id": {
   550                "$oid": "000000000000000000000001"
   551              },
   552              "length": 0,
   553              "chunkSize": 4,
   554              "uploadDate": {
   555                "$date": "1970-01-01T00:00:00.000Z"
   556              },
   557              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   558              "filename": "length-0",
   559              "contentType": "application/octet-stream",
   560              "aliases": [],
   561              "metadata": {}
   562            },
   563            {
   564              "_id": {
   565                "$oid": "000000000000000000000002"
   566              },
   567              "length": 0,
   568              "chunkSize": 4,
   569              "uploadDate": {
   570                "$date": "1970-01-01T00:00:00.000Z"
   571              },
   572              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   573              "filename": "length-0-with-empty-chunk",
   574              "contentType": "application/octet-stream",
   575              "aliases": [],
   576              "metadata": {}
   577            },
   578            {
   579              "_id": {
   580                "$oid": "000000000000000000000003"
   581              },
   582              "length": 2,
   583              "chunkSize": 4,
   584              "uploadDate": {
   585                "$date": "1970-01-01T00:00:00.000Z"
   586              },
   587              "md5": "c700ed4fdb1d27055aa3faa2c2432283",
   588              "filename": "length-2",
   589              "contentType": "application/octet-stream",
   590              "aliases": [],
   591              "metadata": {}
   592            },
   593            {
   594              "_id": {
   595                "$oid": "000000000000000000000004"
   596              },
   597              "length": 8,
   598              "chunkSize": 4,
   599              "uploadDate": {
   600                "$date": "1970-01-01T00:00:00.000Z"
   601              },
   602              "md5": "dd254cdc958e53abaa67da9f797125f5",
   603              "filename": "length-8",
   604              "contentType": "application/octet-stream",
   605              "aliases": [],
   606              "metadata": {}
   607            }
   608          ]
   609        },
   610        {
   611          "collectionName": "fs.chunks",
   612          "databaseName": "gridfs-tests",
   613          "documents": [
   614            {
   615              "_id": {
   616                "$oid": "000000000000000000000001"
   617              },
   618              "files_id": {
   619                "$oid": "000000000000000000000002"
   620              },
   621              "n": 0,
   622              "data": {
   623                "$binary": {
   624                  "base64": "",
   625                  "subType": "00"
   626                }
   627              }
   628            },
   629            {
   630              "_id": {
   631                "$oid": "000000000000000000000002"
   632              },
   633              "files_id": {
   634                "$oid": "000000000000000000000003"
   635              },
   636              "n": 0,
   637              "data": {
   638                "$binary": {
   639                  "base64": "ESI=",
   640                  "subType": "00"
   641                }
   642              }
   643            },
   644            {
   645              "_id": {
   646                "$oid": "000000000000000000000003"
   647              },
   648              "files_id": {
   649                "$oid": "000000000000000000000004"
   650              },
   651              "n": 0,
   652              "data": {
   653                "$binary": {
   654                  "base64": "ESIzRA==",
   655                  "subType": "00"
   656                }
   657              }
   658            },
   659            {
   660              "_id": {
   661                "$oid": "000000000000000000000004"
   662              },
   663              "files_id": {
   664                "$oid": "000000000000000000000004"
   665              },
   666              "n": 1,
   667              "data": {
   668                "$binary": {
   669                  "base64": "VWZ3iA==",
   670                  "subType": "00"
   671                }
   672              }
   673            }
   674          ]
   675        }
   676      ]
   677    },
   678    {
   679      "description": "delete when files entry does not exist and there are orphaned chunks",
   680      "operations": [
   681        {
   682          "name": "deleteOne",
   683          "object": "bucket0_files_collection",
   684          "arguments": {
   685            "filter": {
   686              "_id": {
   687                "$oid": "000000000000000000000004"
   688              }
   689            }
   690          },
   691          "expectResult": {
   692            "deletedCount": 1
   693          }
   694        },
   695        {
   696          "name": "delete",
   697          "object": "bucket0",
   698          "arguments": {
   699            "id": {
   700              "$oid": "000000000000000000000004"
   701            }
   702          },
   703          "expectError": {
   704            "isError": true
   705          }
   706        }
   707      ],
   708      "outcome": [
   709        {
   710          "collectionName": "fs.files",
   711          "databaseName": "gridfs-tests",
   712          "documents": [
   713            {
   714              "_id": {
   715                "$oid": "000000000000000000000001"
   716              },
   717              "length": 0,
   718              "chunkSize": 4,
   719              "uploadDate": {
   720                "$date": "1970-01-01T00:00:00.000Z"
   721              },
   722              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   723              "filename": "length-0",
   724              "contentType": "application/octet-stream",
   725              "aliases": [],
   726              "metadata": {}
   727            },
   728            {
   729              "_id": {
   730                "$oid": "000000000000000000000002"
   731              },
   732              "length": 0,
   733              "chunkSize": 4,
   734              "uploadDate": {
   735                "$date": "1970-01-01T00:00:00.000Z"
   736              },
   737              "md5": "d41d8cd98f00b204e9800998ecf8427e",
   738              "filename": "length-0-with-empty-chunk",
   739              "contentType": "application/octet-stream",
   740              "aliases": [],
   741              "metadata": {}
   742            },
   743            {
   744              "_id": {
   745                "$oid": "000000000000000000000003"
   746              },
   747              "length": 2,
   748              "chunkSize": 4,
   749              "uploadDate": {
   750                "$date": "1970-01-01T00:00:00.000Z"
   751              },
   752              "md5": "c700ed4fdb1d27055aa3faa2c2432283",
   753              "filename": "length-2",
   754              "contentType": "application/octet-stream",
   755              "aliases": [],
   756              "metadata": {}
   757            }
   758          ]
   759        },
   760        {
   761          "collectionName": "fs.chunks",
   762          "databaseName": "gridfs-tests",
   763          "documents": [
   764            {
   765              "_id": {
   766                "$oid": "000000000000000000000001"
   767              },
   768              "files_id": {
   769                "$oid": "000000000000000000000002"
   770              },
   771              "n": 0,
   772              "data": {
   773                "$binary": {
   774                  "base64": "",
   775                  "subType": "00"
   776                }
   777              }
   778            },
   779            {
   780              "_id": {
   781                "$oid": "000000000000000000000002"
   782              },
   783              "files_id": {
   784                "$oid": "000000000000000000000003"
   785              },
   786              "n": 0,
   787              "data": {
   788                "$binary": {
   789                  "base64": "ESI=",
   790                  "subType": "00"
   791                }
   792              }
   793            }
   794          ]
   795        }
   796      ]
   797    }
   798  ]
   799}

View as plain text