Skip to content

TOOLS-4263 Convert mongofiles put and storage-option tests to Go - #1138

Draft
autarch wants to merge 1 commit into
08-13-tools-4263_drop_the_mopt_alias_for_the_driver_s_options_packagefrom
08-14-tools-4263_convert_mongofiles_put_and_storage-option_tests_to_go
Draft

TOOLS-4263 Convert mongofiles put and storage-option tests to Go#1138
autarch wants to merge 1 commit into
08-13-tools-4263_drop_the_mopt_alias_for_the_driver_s_options_packagefrom
08-14-tools-4263_convert_mongofiles_put_and_storage-option_tests_to_go

Conversation

@autarch

@autarch autarch commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Six jstests/files tests covered mongofiles' storage options — --replace,
--prefix, --type, --db, --local — and putting a file much larger than one
GridFS chunk. This replaces them with testify tests in the mongofiles package,
in a new file so the existing GoConvey blocks are left alone.

  • test/qa-tests/jstests/files/mongofiles_replace.js -> TestPutReplace and
    TestPutIDRejectsDuplicateID in mongofiles/put_options_test.go - three puts
    of one file leave three fs.files docs, --replace collapses them to one and
    leaves one copy of each other file, and a second put_id with the same _id
    fails with a duplicate-key error without disturbing that file's chunks.
  • test/qa-tests/jstests/files/mongofiles_prefix.js -> TestGridFSPrefix - a
    default put writes to fs.*, --prefix custom writes to custom.files and
    custom.chunks and nothing to fs.files, and a get through the same prefix
    returns identical bytes.
  • test/qa-tests/jstests/files/mongofiles_type.js -> TestPutContentType -
    --type is stored as metadata.contentType, a put without it stores no
    content type, and the typed file still round-trips byte for byte.
  • test/qa-tests/jstests/files/mongofiles_db.js -> TestPutIntoOtherDB - both
    puts land in the database named by --db and the default database stays
    empty.
  • test/qa-tests/jstests/files/mongofiles_local.js -> TestPutLocalFileName
    and TestEmptyLocalFileName - --local supplies the bytes while the
    positional argument names the GridFS file, a missing --local path is an
    error, and an empty --local falls back to the GridFS name for both put
    (an error when no local file has that name) and get.
  • test/qa-tests/jstests/files/mongofiles_put.js -> TestPutLargeFile - a 40MB
    file is stored with the right length and ceil(length/chunkSize) chunks and
    comes back byte for byte, and putting a directory fails.

The JS tests drove the compiled binary and so also exercised flag parsing (-d,
-t, -l) and ran against standalone, replica set and sharded topologies with
and without auth. Like the rest of this package, the Go tests build MongoFiles
values directly, so they cover the option behavior but not the flag wiring, and
they run against whichever server the integration suite is pointed at.

The jstests/files/*.js glob in the resmoke suites still matches the JS tests
that have yet to be converted, so no suite config changes are needed yet.

autarch commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Six `jstests/files` tests covered mongofiles' storage options — `--replace`,
`--prefix`, `--type`, `--db`, `--local` — and putting a file much larger than one
GridFS chunk. This replaces them with testify tests in the `mongofiles` package,
in a new file so the existing GoConvey blocks are left alone.

* `test/qa-tests/jstests/files/mongofiles_replace.js` -> `TestPutReplace` and
  `TestPutIDRejectsDuplicateID` in `mongofiles/put_options_test.go` - three puts
  of one file leave three `fs.files` docs, `--replace` collapses them to one and
  leaves one copy of each other file, and a second `put_id` with the same `_id`
  fails with a duplicate-key error without disturbing that file's chunks.
* `test/qa-tests/jstests/files/mongofiles_prefix.js` -> `TestGridFSPrefix` - a
  default put writes to `fs.*`, `--prefix custom` writes to `custom.files` and
  `custom.chunks` and nothing to `fs.files`, and a get through the same prefix
  returns identical bytes.
* `test/qa-tests/jstests/files/mongofiles_type.js` -> `TestPutContentType` -
  `--type` is stored as `metadata.contentType`, a put without it stores no
  content type, and the typed file still round-trips byte for byte.
* `test/qa-tests/jstests/files/mongofiles_db.js` -> `TestPutIntoOtherDB` - both
  puts land in the database named by `--db` and the default database stays
  empty.
* `test/qa-tests/jstests/files/mongofiles_local.js` -> `TestPutLocalFileName`
  and `TestEmptyLocalFileName` - `--local` supplies the bytes while the
  positional argument names the GridFS file, a missing `--local` path is an
  error, and an empty `--local` falls back to the GridFS name for both put
  (an error when no local file has that name) and get.
* `test/qa-tests/jstests/files/mongofiles_put.js` -> `TestPutLargeFile` - a 40MB
  file is stored with the right `length` and `ceil(length/chunkSize)` chunks and
  comes back byte for byte, and putting a directory fails.

The JS tests drove the compiled binary and so also exercised flag parsing (`-d`,
`-t`, `-l`) and ran against standalone, replica set and sharded topologies with
and without auth. Like the rest of this package, the Go tests build `MongoFiles`
values directly, so they cover the option behavior but not the flag wiring, and
they run against whichever server the integration suite is pointed at.

The `jstests/files/*.js` glob in the resmoke suites still matches the JS tests
that have yet to be converted, so no suite config changes are needed yet.

The JS tests also asserted that an empty `--local` fails on Windows while it succeeds
elsewhere, without recording why. They passed a path with a directory component;
`TestEmptyLocalFileName` uses a bare file name in a temporary working directory, where
`getLocalFileName`'s fallback has nothing platform-specific left in it, so no Windows
branch is carried over.
@autarch
autarch force-pushed the 08-13-tools-4263_drop_the_mopt_alias_for_the_driver_s_options_package branch from 76d1300 to b2f6ffa Compare August 25, 2026 20:18
@autarch
autarch force-pushed the 08-14-tools-4263_convert_mongofiles_put_and_storage-option_tests_to_go branch from 182aae0 to 5666277 Compare August 25, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant