README.rst
1=======================
2URI Options Tests
3=======================
4
5The YAML and JSON files in this directory tree are platform-independent tests
6that drivers can use to prove their conformance to the URI Options spec.
7
8These tests use the same format as the Connection String spec tests.
9
10Version
11-------
12
13Files in the "specifications" repository have no version scheme. They are not
14tied to a MongoDB server version.
15
16Format
17------
18
19Each YAML file contains an object with a single ``tests`` key. This key is an
20array 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
34If 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
36test files (keys should always exist) and allows flexibility for drivers that
37might substitute default values *during* parsing (e.g. omitted ``hosts`` could be
38parsed as ``["localhost"]``).
39
40The ``valid`` and ``warning`` fields are boolean in order to keep the tests
41flexible. We are not concerned with asserting the format of specific error or
42warnings messages strings.
43
44Use as unit tests
45=================
46
47Testing whether a URI is valid or not requires testing whether URI parsing (or
48MongoClient construction) causes a warning due to a URI option being invalid and asserting that the
49options parsed from the URI match those listed in the ``options`` field.
50
51Note that there are tests for each of the options marked as optional; drivers will need to implement
52logic to skip over the optional tests that they don’t implement.
53