...

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

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

     1{
     2  "description": "gridfs-upload",
     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    {
    45      "collectionName": "fs.chunks",
    46      "databaseName": "gridfs-tests",
    47      "documents": []
    48    }
    49  ],
    50  "tests": [
    51    {
    52      "description": "upload when length is 0",
    53      "operations": [
    54        {
    55          "name": "upload",
    56          "object": "bucket0",
    57          "arguments": {
    58            "filename": "filename",
    59            "source": {
    60              "$$hexBytes": ""
    61            },
    62            "chunkSizeBytes": 4
    63          },
    64          "expectResult": {
    65            "$$type": "objectId"
    66          },
    67          "saveResultAsEntity": "uploadedObjectId"
    68        },
    69        {
    70          "name": "find",
    71          "object": "bucket0_files_collection",
    72          "arguments": {
    73            "filter": {}
    74          },
    75          "expectResult": [
    76            {
    77              "_id": {
    78                "$$matchesEntity": "uploadedObjectId"
    79              },
    80              "length": 0,
    81              "chunkSize": 4,
    82              "uploadDate": {
    83                "$$type": "date"
    84              },
    85              "md5": {
    86                "$$unsetOrMatches": "d41d8cd98f00b204e9800998ecf8427e"
    87              },
    88              "filename": "filename"
    89            }
    90          ]
    91        },
    92        {
    93          "name": "find",
    94          "object": "bucket0_chunks_collection",
    95          "arguments": {
    96            "filter": {}
    97          },
    98          "expectResult": []
    99        }
   100      ]
   101    },
   102    {
   103      "description": "upload when length is 1",
   104      "operations": [
   105        {
   106          "name": "upload",
   107          "object": "bucket0",
   108          "arguments": {
   109            "filename": "filename",
   110            "source": {
   111              "$$hexBytes": "11"
   112            },
   113            "chunkSizeBytes": 4
   114          },
   115          "expectResult": {
   116            "$$type": "objectId"
   117          },
   118          "saveResultAsEntity": "uploadedObjectId"
   119        },
   120        {
   121          "name": "find",
   122          "object": "bucket0_files_collection",
   123          "arguments": {
   124            "filter": {}
   125          },
   126          "expectResult": [
   127            {
   128              "_id": {
   129                "$$matchesEntity": "uploadedObjectId"
   130              },
   131              "length": 1,
   132              "chunkSize": 4,
   133              "uploadDate": {
   134                "$$type": "date"
   135              },
   136              "md5": {
   137                "$$unsetOrMatches": "47ed733b8d10be225eceba344d533586"
   138              },
   139              "filename": "filename"
   140            }
   141          ]
   142        },
   143        {
   144          "name": "find",
   145          "object": "bucket0_chunks_collection",
   146          "arguments": {
   147            "filter": {}
   148          },
   149          "expectResult": [
   150            {
   151              "_id": {
   152                "$$type": "objectId"
   153              },
   154              "files_id": {
   155                "$$matchesEntity": "uploadedObjectId"
   156              },
   157              "n": 0,
   158              "data": {
   159                "$binary": {
   160                  "base64": "EQ==",
   161                  "subType": "00"
   162                }
   163              }
   164            }
   165          ]
   166        }
   167      ]
   168    },
   169    {
   170      "description": "upload when length is 3",
   171      "operations": [
   172        {
   173          "name": "upload",
   174          "object": "bucket0",
   175          "arguments": {
   176            "filename": "filename",
   177            "source": {
   178              "$$hexBytes": "112233"
   179            },
   180            "chunkSizeBytes": 4
   181          },
   182          "expectResult": {
   183            "$$type": "objectId"
   184          },
   185          "saveResultAsEntity": "uploadedObjectId"
   186        },
   187        {
   188          "name": "find",
   189          "object": "bucket0_files_collection",
   190          "arguments": {
   191            "filter": {}
   192          },
   193          "expectResult": [
   194            {
   195              "_id": {
   196                "$$matchesEntity": "uploadedObjectId"
   197              },
   198              "length": 3,
   199              "chunkSize": 4,
   200              "uploadDate": {
   201                "$$type": "date"
   202              },
   203              "md5": {
   204                "$$unsetOrMatches": "bafae3a174ab91fc70db7a6aa50f4f52"
   205              },
   206              "filename": "filename"
   207            }
   208          ]
   209        },
   210        {
   211          "name": "find",
   212          "object": "bucket0_chunks_collection",
   213          "arguments": {
   214            "filter": {}
   215          },
   216          "expectResult": [
   217            {
   218              "_id": {
   219                "$$type": "objectId"
   220              },
   221              "files_id": {
   222                "$$matchesEntity": "uploadedObjectId"
   223              },
   224              "n": 0,
   225              "data": {
   226                "$binary": {
   227                  "base64": "ESIz",
   228                  "subType": "00"
   229                }
   230              }
   231            }
   232          ]
   233        }
   234      ]
   235    },
   236    {
   237      "description": "upload when length is 4",
   238      "operations": [
   239        {
   240          "name": "upload",
   241          "object": "bucket0",
   242          "arguments": {
   243            "filename": "filename",
   244            "source": {
   245              "$$hexBytes": "11223344"
   246            },
   247            "chunkSizeBytes": 4
   248          },
   249          "expectResult": {
   250            "$$type": "objectId"
   251          },
   252          "saveResultAsEntity": "uploadedObjectId"
   253        },
   254        {
   255          "name": "find",
   256          "object": "bucket0_files_collection",
   257          "arguments": {
   258            "filter": {}
   259          },
   260          "expectResult": [
   261            {
   262              "_id": {
   263                "$$matchesEntity": "uploadedObjectId"
   264              },
   265              "length": 4,
   266              "chunkSize": 4,
   267              "uploadDate": {
   268                "$$type": "date"
   269              },
   270              "md5": {
   271                "$$unsetOrMatches": "7e7c77cff5705d1f7574a25ef6662117"
   272              },
   273              "filename": "filename"
   274            }
   275          ]
   276        },
   277        {
   278          "name": "find",
   279          "object": "bucket0_chunks_collection",
   280          "arguments": {
   281            "filter": {}
   282          },
   283          "expectResult": [
   284            {
   285              "_id": {
   286                "$$type": "objectId"
   287              },
   288              "files_id": {
   289                "$$matchesEntity": "uploadedObjectId"
   290              },
   291              "n": 0,
   292              "data": {
   293                "$binary": {
   294                  "base64": "ESIzRA==",
   295                  "subType": "00"
   296                }
   297              }
   298            }
   299          ]
   300        }
   301      ]
   302    },
   303    {
   304      "description": "upload when length is 5",
   305      "operations": [
   306        {
   307          "name": "upload",
   308          "object": "bucket0",
   309          "arguments": {
   310            "filename": "filename",
   311            "source": {
   312              "$$hexBytes": "1122334455"
   313            },
   314            "chunkSizeBytes": 4
   315          },
   316          "expectResult": {
   317            "$$type": "objectId"
   318          },
   319          "saveResultAsEntity": "uploadedObjectId"
   320        },
   321        {
   322          "name": "find",
   323          "object": "bucket0_files_collection",
   324          "arguments": {
   325            "filter": {}
   326          },
   327          "expectResult": [
   328            {
   329              "_id": {
   330                "$$matchesEntity": "uploadedObjectId"
   331              },
   332              "length": 5,
   333              "chunkSize": 4,
   334              "uploadDate": {
   335                "$$type": "date"
   336              },
   337              "md5": {
   338                "$$unsetOrMatches": "283d4fea5dded59cf837d3047328f5af"
   339              },
   340              "filename": "filename"
   341            }
   342          ]
   343        },
   344        {
   345          "name": "find",
   346          "object": "bucket0_chunks_collection",
   347          "arguments": {
   348            "filter": {},
   349            "sort": {
   350              "n": 1
   351            }
   352          },
   353          "expectResult": [
   354            {
   355              "_id": {
   356                "$$type": "objectId"
   357              },
   358              "files_id": {
   359                "$$matchesEntity": "uploadedObjectId"
   360              },
   361              "n": 0,
   362              "data": {
   363                "$binary": {
   364                  "base64": "ESIzRA==",
   365                  "subType": "00"
   366                }
   367              }
   368            },
   369            {
   370              "_id": {
   371                "$$type": "objectId"
   372              },
   373              "files_id": {
   374                "$$matchesEntity": "uploadedObjectId"
   375              },
   376              "n": 1,
   377              "data": {
   378                "$binary": {
   379                  "base64": "VQ==",
   380                  "subType": "00"
   381                }
   382              }
   383            }
   384          ]
   385        }
   386      ]
   387    },
   388    {
   389      "description": "upload when length is 8",
   390      "operations": [
   391        {
   392          "name": "upload",
   393          "object": "bucket0",
   394          "arguments": {
   395            "filename": "filename",
   396            "source": {
   397              "$$hexBytes": "1122334455667788"
   398            },
   399            "chunkSizeBytes": 4
   400          },
   401          "expectResult": {
   402            "$$type": "objectId"
   403          },
   404          "saveResultAsEntity": "uploadedObjectId"
   405        },
   406        {
   407          "name": "find",
   408          "object": "bucket0_files_collection",
   409          "arguments": {
   410            "filter": {}
   411          },
   412          "expectResult": [
   413            {
   414              "_id": {
   415                "$$matchesEntity": "uploadedObjectId"
   416              },
   417              "length": 8,
   418              "chunkSize": 4,
   419              "uploadDate": {
   420                "$$type": "date"
   421              },
   422              "md5": {
   423                "$$unsetOrMatches": "dd254cdc958e53abaa67da9f797125f5"
   424              },
   425              "filename": "filename"
   426            }
   427          ]
   428        },
   429        {
   430          "name": "find",
   431          "object": "bucket0_chunks_collection",
   432          "arguments": {
   433            "filter": {},
   434            "sort": {
   435              "n": 1
   436            }
   437          },
   438          "expectResult": [
   439            {
   440              "_id": {
   441                "$$type": "objectId"
   442              },
   443              "files_id": {
   444                "$$matchesEntity": "uploadedObjectId"
   445              },
   446              "n": 0,
   447              "data": {
   448                "$binary": {
   449                  "base64": "ESIzRA==",
   450                  "subType": "00"
   451                }
   452              }
   453            },
   454            {
   455              "_id": {
   456                "$$type": "objectId"
   457              },
   458              "files_id": {
   459                "$$matchesEntity": "uploadedObjectId"
   460              },
   461              "n": 1,
   462              "data": {
   463                "$binary": {
   464                  "base64": "VWZ3iA==",
   465                  "subType": "00"
   466                }
   467              }
   468            }
   469          ]
   470        }
   471      ]
   472    },
   473    {
   474      "description": "upload when contentType is provided",
   475      "operations": [
   476        {
   477          "name": "upload",
   478          "object": "bucket0",
   479          "arguments": {
   480            "filename": "filename",
   481            "source": {
   482              "$$hexBytes": "11"
   483            },
   484            "chunkSizeBytes": 4,
   485            "contentType": "image/jpeg"
   486          },
   487          "expectResult": {
   488            "$$type": "objectId"
   489          },
   490          "saveResultAsEntity": "uploadedObjectId"
   491        },
   492        {
   493          "name": "find",
   494          "object": "bucket0_files_collection",
   495          "arguments": {
   496            "filter": {}
   497          },
   498          "expectResult": [
   499            {
   500              "_id": {
   501                "$$matchesEntity": "uploadedObjectId"
   502              },
   503              "length": 1,
   504              "chunkSize": 4,
   505              "uploadDate": {
   506                "$$type": "date"
   507              },
   508              "md5": {
   509                "$$unsetOrMatches": "47ed733b8d10be225eceba344d533586"
   510              },
   511              "filename": "filename",
   512              "contentType": "image/jpeg"
   513            }
   514          ]
   515        },
   516        {
   517          "name": "find",
   518          "object": "bucket0_chunks_collection",
   519          "arguments": {
   520            "filter": {}
   521          },
   522          "expectResult": [
   523            {
   524              "_id": {
   525                "$$type": "objectId"
   526              },
   527              "files_id": {
   528                "$$matchesEntity": "uploadedObjectId"
   529              },
   530              "n": 0,
   531              "data": {
   532                "$binary": {
   533                  "base64": "EQ==",
   534                  "subType": "00"
   535                }
   536              }
   537            }
   538          ]
   539        }
   540      ]
   541    },
   542    {
   543      "description": "upload when metadata is provided",
   544      "operations": [
   545        {
   546          "name": "upload",
   547          "object": "bucket0",
   548          "arguments": {
   549            "filename": "filename",
   550            "source": {
   551              "$$hexBytes": "11"
   552            },
   553            "chunkSizeBytes": 4,
   554            "metadata": {
   555              "x": 1
   556            }
   557          },
   558          "expectResult": {
   559            "$$type": "objectId"
   560          },
   561          "saveResultAsEntity": "uploadedObjectId"
   562        },
   563        {
   564          "name": "find",
   565          "object": "bucket0_files_collection",
   566          "arguments": {
   567            "filter": {}
   568          },
   569          "expectResult": [
   570            {
   571              "_id": {
   572                "$$matchesEntity": "uploadedObjectId"
   573              },
   574              "length": 1,
   575              "chunkSize": 4,
   576              "uploadDate": {
   577                "$$type": "date"
   578              },
   579              "md5": {
   580                "$$unsetOrMatches": "47ed733b8d10be225eceba344d533586"
   581              },
   582              "filename": "filename",
   583              "metadata": {
   584                "x": 1
   585              }
   586            }
   587          ]
   588        },
   589        {
   590          "name": "find",
   591          "object": "bucket0_chunks_collection",
   592          "arguments": {
   593            "filter": {}
   594          },
   595          "expectResult": [
   596            {
   597              "_id": {
   598                "$$type": "objectId"
   599              },
   600              "files_id": {
   601                "$$matchesEntity": "uploadedObjectId"
   602              },
   603              "n": 0,
   604              "data": {
   605                "$binary": {
   606                  "base64": "EQ==",
   607                  "subType": "00"
   608                }
   609              }
   610            }
   611          ]
   612        }
   613      ]
   614    }
   615  ]
   616}

View as plain text