...

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

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

     1{
     2  "description": "gridfs-downloadByName",
     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": 1,
    48          "chunkSize": 4,
    49          "uploadDate": {
    50            "$date": "1970-01-01T00:00:00.000Z"
    51          },
    52          "md5": "47ed733b8d10be225eceba344d533586",
    53          "filename": "abc",
    54          "contentType": "application/octet-stream",
    55          "aliases": [],
    56          "metadata": {}
    57        },
    58        {
    59          "_id": {
    60            "$oid": "000000000000000000000002"
    61          },
    62          "length": 1,
    63          "chunkSize": 4,
    64          "uploadDate": {
    65            "$date": "1970-01-02T00:00:00.000Z"
    66          },
    67          "md5": "b15835f133ff2e27c7cb28117bfae8f4",
    68          "filename": "abc",
    69          "contentType": "application/octet-stream",
    70          "aliases": [],
    71          "metadata": {}
    72        },
    73        {
    74          "_id": {
    75            "$oid": "000000000000000000000003"
    76          },
    77          "length": 1,
    78          "chunkSize": 4,
    79          "uploadDate": {
    80            "$date": "1970-01-03T00:00:00.000Z"
    81          },
    82          "md5": "eccbc87e4b5ce2fe28308fd9f2a7baf3",
    83          "filename": "abc",
    84          "contentType": "application/octet-stream",
    85          "aliases": [],
    86          "metadata": {}
    87        },
    88        {
    89          "_id": {
    90            "$oid": "000000000000000000000004"
    91          },
    92          "length": 1,
    93          "chunkSize": 4,
    94          "uploadDate": {
    95            "$date": "1970-01-04T00:00:00.000Z"
    96          },
    97          "md5": "f623e75af30e62bbd73d6df5b50bb7b5",
    98          "filename": "abc",
    99          "contentType": "application/octet-stream",
   100          "aliases": [],
   101          "metadata": {}
   102        },
   103        {
   104          "_id": {
   105            "$oid": "000000000000000000000005"
   106          },
   107          "length": 1,
   108          "chunkSize": 4,
   109          "uploadDate": {
   110            "$date": "1970-01-05T00:00:00.000Z"
   111          },
   112          "md5": "4c614360da93c0a041b22e537de151eb",
   113          "filename": "abc",
   114          "contentType": "application/octet-stream",
   115          "aliases": [],
   116          "metadata": {}
   117        }
   118      ]
   119    },
   120    {
   121      "collectionName": "fs.chunks",
   122      "databaseName": "gridfs-tests",
   123      "documents": [
   124        {
   125          "_id": {
   126            "$oid": "000000000000000000000001"
   127          },
   128          "files_id": {
   129            "$oid": "000000000000000000000001"
   130          },
   131          "n": 0,
   132          "data": {
   133            "$binary": {
   134              "base64": "EQ==",
   135              "subType": "00"
   136            }
   137          }
   138        },
   139        {
   140          "_id": {
   141            "$oid": "000000000000000000000002"
   142          },
   143          "files_id": {
   144            "$oid": "000000000000000000000002"
   145          },
   146          "n": 0,
   147          "data": {
   148            "$binary": {
   149              "base64": "Ig==",
   150              "subType": "00"
   151            }
   152          }
   153        },
   154        {
   155          "_id": {
   156            "$oid": "000000000000000000000003"
   157          },
   158          "files_id": {
   159            "$oid": "000000000000000000000003"
   160          },
   161          "n": 0,
   162          "data": {
   163            "$binary": {
   164              "base64": "Mw==",
   165              "subType": "00"
   166            }
   167          }
   168        },
   169        {
   170          "_id": {
   171            "$oid": "000000000000000000000004"
   172          },
   173          "files_id": {
   174            "$oid": "000000000000000000000004"
   175          },
   176          "n": 0,
   177          "data": {
   178            "$binary": {
   179              "base64": "RA==",
   180              "subType": "00"
   181            }
   182          }
   183        },
   184        {
   185          "_id": {
   186            "$oid": "000000000000000000000005"
   187          },
   188          "files_id": {
   189            "$oid": "000000000000000000000005"
   190          },
   191          "n": 0,
   192          "data": {
   193            "$binary": {
   194              "base64": "VQ==",
   195              "subType": "00"
   196            }
   197          }
   198        }
   199      ]
   200    }
   201  ],
   202  "tests": [
   203    {
   204      "description": "downloadByName defaults to latest revision (-1)",
   205      "operations": [
   206        {
   207          "name": "downloadByName",
   208          "object": "bucket0",
   209          "arguments": {
   210            "filename": "abc"
   211          },
   212          "expectResult": {
   213            "$$matchesHexBytes": "55"
   214          }
   215        }
   216      ]
   217    },
   218    {
   219      "description": "downloadByName when revision is 0",
   220      "operations": [
   221        {
   222          "name": "downloadByName",
   223          "object": "bucket0",
   224          "arguments": {
   225            "filename": "abc",
   226            "revision": 0
   227          },
   228          "expectResult": {
   229            "$$matchesHexBytes": "11"
   230          }
   231        }
   232      ]
   233    },
   234    {
   235      "description": "downloadByName when revision is 1",
   236      "operations": [
   237        {
   238          "name": "downloadByName",
   239          "object": "bucket0",
   240          "arguments": {
   241            "filename": "abc",
   242            "revision": 1
   243          },
   244          "expectResult": {
   245            "$$matchesHexBytes": "22"
   246          }
   247        }
   248      ]
   249    },
   250    {
   251      "description": "downloadByName when revision is 2",
   252      "operations": [
   253        {
   254          "name": "downloadByName",
   255          "object": "bucket0",
   256          "arguments": {
   257            "filename": "abc",
   258            "revision": 2
   259          },
   260          "expectResult": {
   261            "$$matchesHexBytes": "33"
   262          }
   263        }
   264      ]
   265    },
   266    {
   267      "description": "downloadByName when revision is -2",
   268      "operations": [
   269        {
   270          "name": "downloadByName",
   271          "object": "bucket0",
   272          "arguments": {
   273            "filename": "abc",
   274            "revision": -2
   275          },
   276          "expectResult": {
   277            "$$matchesHexBytes": "44"
   278          }
   279        }
   280      ]
   281    },
   282    {
   283      "description": "downloadByName when revision is -1",
   284      "operations": [
   285        {
   286          "name": "downloadByName",
   287          "object": "bucket0",
   288          "arguments": {
   289            "filename": "abc",
   290            "revision": -1
   291          },
   292          "expectResult": {
   293            "$$matchesHexBytes": "55"
   294          }
   295        }
   296      ]
   297    },
   298    {
   299      "description": "downloadByName when files entry does not exist",
   300      "operations": [
   301        {
   302          "name": "downloadByName",
   303          "object": "bucket0",
   304          "arguments": {
   305            "filename": "xyz"
   306          },
   307          "expectError": {
   308            "isError": true
   309          }
   310        }
   311      ]
   312    },
   313    {
   314      "description": "downloadByName when revision does not exist",
   315      "operations": [
   316        {
   317          "name": "downloadByName",
   318          "object": "bucket0",
   319          "arguments": {
   320            "filename": "abc",
   321            "revision": 999
   322          },
   323          "expectError": {
   324            "isError": true
   325          }
   326        }
   327      ]
   328    }
   329  ]
   330}

View as plain text