Skip to content

Commit 8b86f45

Browse files
committed
skip auth tests if credentials aren't provided
Don't attempt auth tests if MONGOC_TEST_USER isn't defined in the environment.
1 parent 3a12cca commit 8b86f45

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/test-mongoc-client.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ test_mongoc_client_authenticate (void *context)
133133
mongoc_database_destroy (database);
134134
mongoc_client_destroy (admin_client);
135135
}
136+
137+
136138
int should_run_auth_tests (void)
137139
{
140+
char *user;
138141
#ifndef MONGOC_ENABLE_SSL
139142
mongoc_client_t *client = test_framework_client_new (NULL);
140143
uint32_t server_id = mongoc_cluster_preselect(&client->cluster, MONGOC_OPCODE_QUERY, NULL, NULL);
@@ -145,7 +148,10 @@ int should_run_auth_tests (void)
145148
}
146149
#endif
147150

148-
return 1;
151+
/* run auth tests if the MONGOC_TEST_USER env var is set */
152+
user = test_framework_get_admin_user ();
153+
bson_free (user);
154+
return user ? 1 : 0;
149155
}
150156

151157

@@ -714,6 +720,10 @@ test_exhaust_cursor (void)
714720
uint32_t local_hint;
715721

716722
r = mongoc_cursor_next (cursor, &doc);
723+
if (!r) {
724+
mongoc_cursor_error (cursor, &error);
725+
printf ("cursor error: %s\n", error.message);
726+
}
717727
assert (r);
718728
assert (doc);
719729
assert (cursor->in_exhaust);

0 commit comments

Comments
 (0)