|
| 1 | +======================= |
| 2 | +URI Options Tests |
| 3 | +======================= |
| 4 | + |
| 5 | +The YAML and JSON files in this directory tree are platform-independent tests |
| 6 | +that drivers can use to prove their conformance to the URI Options spec. |
| 7 | + |
| 8 | +These tests use the same format as the Connection String spec tests. |
| 9 | + |
| 10 | +Version |
| 11 | +------- |
| 12 | + |
| 13 | +Files in the "specifications" repository have no version scheme. They are not |
| 14 | +tied to a MongoDB server version. |
| 15 | + |
| 16 | +Format |
| 17 | +------ |
| 18 | + |
| 19 | +Each YAML file contains an object with a single ``tests`` key. This key is an |
| 20 | +array of test case objects, each of which have the following keys: |
| 21 | + |
| 22 | +- ``description``: A string describing the test. |
| 23 | +- ``uri``: A string containing the URI to be parsed. |
| 24 | +- ``valid``: A boolean indicating if the URI should be considered valid. |
| 25 | + This will always be true, as the Connection String spec tests the validity of the structure, but |
| 26 | + it's still included to make it easier to reuse the connection string spec test runners that |
| 27 | + drivers already have. |
| 28 | +- ``warning``: A boolean indicating whether URI parsing should emit a warning. |
| 29 | +- ``hosts``: Included for compatibility with the Connection String spec tests. This will always be ``~``. |
| 30 | +- ``auth``: Included for compatibility with the Connection String spec tests. This will always be ``~``. |
| 31 | +- ``options``: An object containing key/value pairs for each parsed query string |
| 32 | + option. |
| 33 | + |
| 34 | +If a test case includes a null value for one of these keys (e.g. ``auth: ~``, |
| 35 | +``hosts: ~``), no assertion is necessary. This both simplifies parsing of the |
| 36 | +test files (keys should always exist) and allows flexibility for drivers that |
| 37 | +might substitute default values *during* parsing (e.g. omitted ``hosts`` could be |
| 38 | +parsed as ``["localhost"]``). |
| 39 | + |
| 40 | +The ``valid`` and ``warning`` fields are boolean in order to keep the tests |
| 41 | +flexible. We are not concerned with asserting the format of specific error or |
| 42 | +warnings messages strings. |
| 43 | + |
| 44 | +Use as unit tests |
| 45 | +================= |
| 46 | + |
| 47 | +Testing whether a URI is valid or not requires testing whether URI parsing (or |
| 48 | +MongoClient construction) causes a warning due to a URI option being invalid and asserting that the |
| 49 | +options parsed from the URI match those listed in the ``options`` field. |
| 50 | + |
| 51 | +Note that there are tests for each of the options marked as optional; drivers will need to implement |
| 52 | +logic to skip over the optional tests that they don’t implement. |
0 commit comments