Skip to content

Commit b4182ec

Browse files
committed
simplify check_schema_version
1 parent 0394f43 commit b4182ec

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

src/libmongoc/tests/unified/runner.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -571,31 +571,28 @@ get_topology_type (mongoc_client_t *client)
571571
static void
572572
check_schema_version (test_file_t *test_file)
573573
{
574-
const char *supported_version_strs[] = {
575-
"1.8", /* fully supported through this version */
576-
"1.12", /* partially supported (expectedError.errorResponse assertions) */
577-
"1.18" /* partially supported (additional properties in kmsProviders) */
578-
"1.20" /* partially supported (expectedError.writeErrors and
579-
expectedError.writeConcernErrors) */
580-
};
581-
int i;
582-
583-
for (i = 0; i < sizeof (supported_version_strs) / sizeof (supported_version_strs[0]); i++) {
584-
semver_t supported_version;
585-
586-
semver_parse (supported_version_strs[i], &supported_version);
587-
if (supported_version.major != test_file->schema_version.major) {
588-
continue;
589-
}
590-
if (!supported_version.has_minor) {
591-
/* All minor versions for this major version are supported. */
592-
return;
593-
}
594-
if (supported_version.minor >= test_file->schema_version.minor) {
595-
return;
596-
}
574+
// `schema_version` is the latest schema version the test runner will try to run.
575+
// 1.8 is fully supported. Later minor versions are partially supported.
576+
// 1.12 is partially supported (expectedError.errorResponse assertions)
577+
// 1.18 is partially supported (additional properties in kmsProviders)
578+
// 1.20 is partially supported (expectedError.writeErrors and expectedError.writeConcernErrors)
579+
semver_t schema_version;
580+
semver_parse ("1.20", &schema_version);
581+
582+
if (schema_version.major != test_file->schema_version.major) {
583+
goto fail;
584+
}
585+
586+
if (!schema_version.has_minor) {
587+
/* All minor versions for this major version are supported. */
588+
return;
589+
}
590+
591+
if (schema_version.minor >= test_file->schema_version.minor) {
592+
return;
597593
}
598594

595+
fail:
599596
test_error ("Unsupported schema version: %s", semver_to_string (&test_file->schema_version));
600597
}
601598

0 commit comments

Comments
 (0)